From 55d2c6d0cb3211c3aa57669c74546225fd985ac6 Mon Sep 17 00:00:00 2001 From: Steven Baltakatei Sandoval Date: Tue, 16 Jul 2024 00:03:42 +0000 Subject: [PATCH] feat(unitproc/bkt-remove-leading_zeroes):Remove read_stdin() --- unitproc/bkt-remove_leading_zeroes | 38 ++---------------------------- 1 file changed, 2 insertions(+), 36 deletions(-) diff --git a/unitproc/bkt-remove_leading_zeroes b/unitproc/bkt-remove_leading_zeroes index d934e93..503dd40 100755 --- a/unitproc/bkt-remove_leading_zeroes +++ b/unitproc/bkt-remove_leading_zeroes @@ -1,48 +1,14 @@ #!/bin/bash -read_stdin() { - # Desc: Consumes stdin; outputs as stdout lines - # Input: stdin (consumes) - # Output: stdout (newline delimited) - # return 0 stdin read - # return 1 stdin not present - # Example: printf "foo\nbar\n" | read_stdin - # Depends: GNU bash (version 5.1.16), GNU Coreutils 8.32 (cat) - # Version: 0.1.1 - # Attrib: Steven Baltakatei Sandoval (2024-01-29). reboil.com - local input_stdin output; - - # Store stdin - if [[ -p /dev/stdin ]]; then - input_stdin="$(cat -)" || { - echo "FATAL:Error reading stdin." 1>&2; return 1; }; - else - return 1; - fi; - - # Store as output array elements - ## Read in stdin - if [[ -n $input_stdin ]]; then - while read -r line; do - output+=("$line"); - done < <(printf "%s\n" "$input_stdin") || { - echo "FATAL:Error parsing stdin."; return 1; }; - fi; - - # Print to stdout - printf "%s\n" "${output[@]}"; - - return 0; -}; # read stdin to stdout lines remove_leading_zeroes() { # Desc: Removes leading zeroes from lines # Input: stdin # Output: stdout # Depends: BK-2020-03 read_stdin() - # Version: 0.0.1 + # Version: 0.0.2 while read -r line; do printf "%s\n" "$line" | sed -E -e 's/(^0*)([0-9].*)/\2/'; - done < <(read_stdin); + done; }; printf "00000.jpg\n0001.jpg\n2.jpg\n000003.jpg\n0010.jpg\n"; -- 2.30.2