Skip to content

Commit

Permalink
bash v3 compat
Browse files Browse the repository at this point in the history
  • Loading branch information
balupton committed Sep 15, 2024
1 parent 7c7ed59 commit a1f96ea
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion commands.beta/get-codec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion commands.beta/is-audio-mono
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion commands.beta/is-audio-stereo
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion commands.beta/itunes-owners
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion commands/eval-helper
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions commands/fs-speed
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")"
Expand All @@ -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")"
Expand Down
2 changes: 1 addition & 1 deletion commands/setup-git
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a1f96ea

Please sign in to comment.