823f4129f0ffa5ba250019f3d90012d6348f1c2a
2 # Desc: Adds blank line every 4 lines
3 # Usage: cat file | space4
4 # Example: seq 1 10 | space 4
8 yell
() { echo "$0: $*" >&2; } # print script path and all args to stderr
9 die
() { yell
"$*"; exit 111; } # same as yell() but non-zero exit status
10 must
() { "$@" || die
"cannot $*"; } # runs args as command, reports args if command fails
12 # Desc: Consumes stdin; outputs as stdout lines
13 # Input: stdin (consumes)
14 # Output: stdout (newline delimited)
15 # Example: printf "foo\nbar\n" | read_stdin
16 # Depends: GNU bash (version 5.1.16)
18 local input_stdin output
;
21 if [[ -p /dev
/stdin
]]; then
22 input_stdin
="$(cat -)";
25 # Store as output array elements
27 if [[ -n $input_stdin ]]; then
28 while read -r line
; do
30 done < <(printf "%s\n" "$input_stdin");
34 printf "%s\n" "${output[@]}";
35 }; # read stdin to stdout lines
37 # Depends: BK-2020-03: yell(), die(), must(), read_stdin()
38 if [[ $# -gt 0 ]]; then die
"FATAL:This script uses no positional arguments.:$#"; fi;
40 while read -r line
; do
41 printf "%s\n" "$line";
42 if ! (( (n
+ 1) % 4 )); then
51 # Author: Steven Baltakatei Sandoval