From a1f96eaa55a5bbcbd71c9bf4aac53e86d061b539 Mon Sep 17 00:00:00 2001 From: Benjamin Lupton Date: Sun, 15 Sep 2024 17:10:14 +0800 Subject: [PATCH] bash v3 compat /ref https://github.com/bevry/dorothy/actions/runs/10869111682/job/30159878666#step:3:99 --- commands.beta/get-codec | 2 +- commands.beta/is-audio-mono | 2 +- commands.beta/is-audio-stereo | 2 +- commands.beta/itunes-owners | 2 +- commands/eval-helper | 2 +- commands/fs-speed | 6 +++--- commands/setup-git | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/commands.beta/get-codec b/commands.beta/get-codec index 7e562d834..802b218ca 100755 --- a/commands.beta/get-codec +++ b/commands.beta/get-codec @@ -76,7 +76,7 @@ function get_codec() ( if test "$option_verbose" = 'no'; then # trunk-ignore(shellcheck/SC2016) - ffprobe -i "$option_path" |& echo-regexp -fon --regexp='Audio: ([\w\d-]+)' --replace='$1' + ffprobe -i "$option_path" 2>&1 | echo-regexp -fon --regexp='Audio: ([\w\d-]+)' --replace='$1' else ffprobe -i "$option_path" fi diff --git a/commands.beta/is-audio-mono b/commands.beta/is-audio-mono index 569688614..3b30154b0 100755 --- a/commands.beta/is-audio-mono +++ b/commands.beta/is-audio-mono @@ -3,7 +3,7 @@ function is_audio_mono() ( source "$DOROTHY/sources/bash.bash" - ffprobe -i "$1" |& grep mono + ffprobe -i "$1" 2>&1 | grep mono ) # fire if invoked standalone diff --git a/commands.beta/is-audio-stereo b/commands.beta/is-audio-stereo index c3b7baee6..39e77ae97 100755 --- a/commands.beta/is-audio-stereo +++ b/commands.beta/is-audio-stereo @@ -3,7 +3,7 @@ function is_audio_stereo() ( source "$DOROTHY/sources/bash.bash" - ffprobe -i "$1" |& grep stereo + ffprobe -i "$1" 2>&1 | grep stereo ) # fire if invoked standalone diff --git a/commands.beta/itunes-owners b/commands.beta/itunes-owners index 96c799bc6..e444fa592 100755 --- a/commands.beta/itunes-owners +++ b/commands.beta/itunes-owners @@ -75,7 +75,7 @@ function itunes_owners() ( # fetch owner # trunk-ignore(shellcheck/SC2016) - owner="$(ffprobe -i "$song" |& echo-regexp -o --regexp='account_id\s*:\s*(.+)' --replace='$1')" + owner="$(ffprobe -i "$song" 2>&1 | echo-regexp -o --regexp='account_id\s*:\s*(.+)' --replace='$1')" # write if test -n "$owner"; then diff --git a/commands/eval-helper b/commands/eval-helper index 08712283a..90ef1940b 100755 --- a/commands/eval-helper +++ b/commands/eval-helper @@ -158,7 +158,7 @@ function eval_helper() ( fi # body - # NOTE |& is bash v4 only, and this script must work on Bash v3 + # NOTE |& is bash v4 only, and this script must work on Bash v3, which uses 2>&1 | # https://github.com/bevry/dorothy/discussions/151 local INSIDE_REVOLVING_DOOR_original="${INSIDE_REVOLVING_DOOR:-"no"}" export INSIDE_REVOLVING_DOOR='yes' # use export, as env doesn't work when option_cmd[0] was a function diff --git a/commands/fs-speed b/commands/fs-speed index a142a6ae4..c3a327ddc 100755 --- a/commands/fs-speed +++ b/commands/fs-speed @@ -2,7 +2,6 @@ # NOTES: # use /dev/random as on macos /dev/zero is instant -# |& is because dd writes to something other than stdout function fs_speed() ( source "$DOROTHY/sources/bash.bash" @@ -127,11 +126,12 @@ fi # fs-rm --quiet --no-confirm -- "$scratchpad" "$log" # # write performance +# # 2>&1 | is because dd writes to something other than stdout # eval-helper --quiet="$option_quiet" \ # --pending="$(echo-style --bold='Calculating write performance...')" \ # --success="$(echo-style --success='Calculated write performance.')" \ # --failure="$(echo-style --error='Failed calculate write.')" \ -# -- dd if=/dev/urandom of="$scratchpad" bs="$bs" count="$count" |& tee "$log" +# -- dd if=/dev/urandom of="$scratchpad" bs="$bs" count="$count" 2>&1 | tee "$log" # bytes="$(echo-regexp -o --regexp='(\d+) bytes/sec' --replace='$1' <"$log")" # if test -n "$bytes"; then # megabytes="$(echo-math --precision=0 -- "$bytes / 1024 / 1024")" @@ -148,7 +148,7 @@ fi # --pending="$(echo-style --bold='Calculating read performance...')" \ # --success="$(echo-style --success='Calculated read performance.')" \ # --failure="$(echo-style --error='Failed calculate read.')" \ -# -- dd if="$scratchpad" of=/dev/zero bs="$bs" |& tee "$log" +# -- dd if="$scratchpad" of=/dev/zero bs="$bs" 2>&1 | tee "$log" # bytes="$(echo-regexp -o --regexp='(\d+) bytes/sec' --replace='$1' <"$log")" # if test -n "$bytes"; then # megabytes="$(echo-math --precision=0 -- "$bytes / 1024 / 1024")" diff --git a/commands/setup-git b/commands/setup-git index ff62a8834..78909827c 100755 --- a/commands/setup-git +++ b/commands/setup-git @@ -486,7 +486,7 @@ function setup_git() ( # glab writes to stderr, grep needed as return status is not indicative # wrap in `! (` is to catch failures in the grep, and in the glab call # setup-util-glab--optional # only install if gitlab is configured - # if ! (glab auth status |& grep --quiet --fixed-strings --regexp='Logged in to '); then + # if ! (glab auth status 2>&1 | grep --quiet --fixed-strings --regexp='Logged in to '); then # glab auth login # fi # ^ currently broken