From 4554c8c3585e7fc5e7e5a7edd4103a0a20b34f4f Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 22 Apr 2020 20:23:44 +1200 Subject: Avoid a fork by shuffling list in place --- parcimini.bash | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/parcimini.bash b/parcimini.bash index 54f2ceb..016f166 100644 --- a/parcimini.bash +++ b/parcimini.bash @@ -24,13 +24,12 @@ END { for (key_id in key_ids) print key_id }' printf >&2 '%s: Started; base interval %u seconds.\n' \ "$self" "$interval" -# While we're able to write the key list to the file, refresh all of them -while key_ids > "$list" ; do +# While we're able to write a shuffled key list to the file, refresh all of them +while key_ids | shuf > "$list" ; do printf >&2 '%s: Beginning new round; %u key IDs found.\n' \ "$self" "$(sed '$=;d' "$list")" # Shuffle list and read each ID - shuf "$list" | while read -r key_id ; do # Sleep for a random interval @@ -44,5 +43,5 @@ while key_ids > "$list" ; do "$self" "$key_id" gpg --batch --no-tty --recv-key "$key_id" - done + done < $list done -- cgit v1.2.3