diff --git a/bin/ap b/bin/ap index 1c598985..355163dc 100755 --- a/bin/ap +++ b/bin/ap @@ -73,14 +73,13 @@ portableReadLink() { usage() { local -r exit_code="${1:-0}" (($# > 0)) && shift - # shellcheck disable=SC2015 - [ "$exit_code" != 0 ] && local -r out=/dev/stderr || local -r out=/dev/stdout + local -r out=$(((exit_code != 0) + 1)) # NOTE: $'foo' is the escape sequence syntax of bash local nl=$'\n' # new line - (($# > 0)) && redPrint "$*$nl" >"$out" + (($# > 0)) && redPrint "$*$nl" >&"$out" - cat >"$out" <&"$out" < 0)) && shift - # shellcheck disable=SC2015 - [ "$exit_code" != 0 ] && local -r out=/dev/stderr || local -r out=/dev/stdout + local -r out=$(((exit_code != 0) + 1)) - (($# > 0)) && printErrorMsg "$*" >"$out" + (($# > 0)) && printErrorMsg "$*" >&"$out" - cat >"$out" <&"$out" < 0)) && shift - # shellcheck disable=SC2015 - [ "$exit_code" != 0 ] && local -r out=/dev/stderr || local -r out=/dev/stdout + local -r out=$(((exit_code != 0) + 1)) # NOTE: $'foo' is the escape sequence syntax of bash local nl=$'\n' # new line - (($# > 0)) && redPrint "$*$nl" >"$out" + (($# > 0)) && redPrint "$*$nl" >&"$out" - cat >"$out" <&"$out" < 0)) && shift - # shellcheck disable=SC2015 - [ "$exit_code" != 0 ] && local -r out=/dev/stderr || local -r out=/dev/stdout + local -r out=$(((exit_code != 0) + 1)) # NOTE: $'foo' is the escape sequence syntax of bash local -r nl=$'\n' # new line - (($# > 0)) && redPrint "$*$nl" >"$out" + (($# > 0)) && redPrint "$*$nl" >&"$out" - cat >"$out" <&"$out" < 0)) && shift - # shellcheck disable=SC2015 - [ "$exit_code" != 0 ] && local -r out=/dev/stderr || local -r out=/dev/stdout + local -r out=$(((exit_code != 0) + 1)) # NOTE: $'foo' is the escape sequence syntax of bash local nl=$'\n' # new line - (($# > 0)) && redPrint "$*$nl" >"$out" + (($# > 0)) && redPrint "$*$nl" >&"$out" - cat >"$out" <&"$out" < 0)) && shift - # shellcheck disable=SC2015 - [ "$exit_code" != 0 ] && local -r out=/dev/stderr || local -r out=/dev/stdout + local -r out=$(((exit_code != 0) + 1)) - (($# > 0)) && colorPrint 31 "$*$nl" >"$out" + (($# > 0)) && colorPrint 31 "$*$nl" >&"$out" - cat >"$out" <&"$out" < 0)) && shift - # shellcheck disable=SC2015 - [ "$exit_code" != 0 ] && local -r out=/dev/stderr || local -r out=/dev/stdout + local -r out=$(((exit_code != 0) + 1)) - (($# > 0)) && redPrint "$*$nl" >"$out" + (($# > 0)) && redPrint "$*$nl" >&"$out" - cat >"$out" <&"$out" < 0)) && shift - # shellcheck disable=SC2015 - [ "$exit_code" != 0 ] && local -r out=/dev/stderr || local -r out=/dev/stdout + local -r out=$(((exit_code != 0) + 1)) - (($# > 0)) && printf '%s\n\n' "$*" >"$out" + (($# > 0)) && printf '%s\n\n' "$*" >&"$out" - cat <&"$out" <