X-Git-Url: https://zdv2.bktei.com/gitweb/BK-2020-03.git/blobdiff_plain/57357d431490ee122e0ea781cd2959d385dec5c5..30f77d36a48f1183c347108ce706b9de9c2a35d1:/unitproc/bkshuf

diff --git a/unitproc/bkshuf b/unitproc/bkshuf
old mode 100644
new mode 100755
index d2d0763..ff80d8e
--- a/unitproc/bkshuf
+++ b/unitproc/bkshuf
@@ -1,10 +1,12 @@
 #!/usr/bin/env bash
 # Desc: Mixes input lines while also preserving some neighbors
 # Usage: cat file | bkshuf arg1
-# Version 0.1.2
+# Version 0.2.0
 # Depends: bc 1.07.1, GNU Coreutils 8.32 (shuf)
 # Input: var: arg1  initial lines to output
 
+trap 'exit;' SIGPIPE; # exit early if stdout not being read
+
 # Load env vars
 ## For these numbers of lines of input...
 if [[ ! -v BKSHUF_PARAM_LINEC ]]; then BKSHUF_PARAM_LINEC=1000000; fi;
@@ -88,7 +90,8 @@ consume_line() {
         line="${list_input[$ip]}";
         if [[ -n $line ]]; then
             ##### consume line at index ip
-            printf "%s\n" "$line" & # print to output
+            printf "%s\n" "$line"; # print to output
+
             unset "list_input[$ip]"; # destroy line in list_input array
             ((lc_out++));
             ((lcr--)); # decrement line count remaining lcr