From: git Date: Sun, 15 Feb 2026 12:46:28 +0000 (-0500) Subject: refined "usage:" error message X-Git-Url: https://git.datadissipation.net/?a=commitdiff_plain;h=9411b5c3a10870974e0a706068f1eb5e934cd0f6;p=baseconv.git refined "usage:" error message --- diff --git a/tobin b/tobin index d9e6830..58c0eae 100755 --- a/tobin +++ b/tobin @@ -28,6 +28,7 @@ conv() { main() { + USAGE="usage: tobin [-mnp] ..." if ! [ "$1" = "x" ] && ! [ -t 0 ]; then cat | tr '\n' ' ' | xargs tobin "x" "$@" return "$?" @@ -38,7 +39,7 @@ main() { fi if [ $# -eq 0 ]; then - printf "Error: No arguments provided\nusage: tobin [-mnp] number1 number2 ...\n" >&2 + printf "Error: No arguments provided\n%s\n" "$USAGE" >&2 return 2 fi @@ -50,7 +51,7 @@ main() { m) m=1; ;; n) n=1; ;; p) p="0b" ;; - *) printf "usage: tobin [-mnp] number1 number2 ...\n" >&2 ; return 2 ;; + *) printf "%s\n" "$USAGE" >&2 ; return 2 ;; esac done diff --git a/todec b/todec index d48311d..feaff7e 100755 --- a/todec +++ b/todec @@ -28,6 +28,7 @@ conv() { main() { + USAGE="usage: todec [-mnKMG] ..." if ! [ "$1" = "x" ] && ! [ -t 0 ]; then cat | tr '\n' ' ' | xargs todec "x" "$@" return "$?" @@ -38,7 +39,7 @@ main() { fi if [ $# -eq 0 ]; then - printf "Error: No arguments provided\nusage: todec [-mn] number1 number2 ...\n" >&2 + printf "Error: No arguments provided\n%s\n" "$USAGE" >&2 return 2 fi @@ -55,7 +56,7 @@ main() { M) k=100000000000000000000; p='M'; ;; # 1 073 741 824 G) k=1000000000000000000000000000000; p='G'; ;; - *) printf "usage: todec [-mnKMG] number1 number2 ...\n" >&2 ; return 2 ;; + *) printf "%s\n" "$USAGE" >&2 ; return 2 ;; esac done diff --git a/tohex b/tohex index e272405..0452e91 100755 --- a/tohex +++ b/tohex @@ -28,6 +28,7 @@ conv() { main() { + USAGE="usage: tohex [-lmnp] ..." if ! [ "$1" = "x" ] && ! [ -t 0 ]; then cat | tr '\n' ' ' | xargs tohex "x" "$@" return "$?" @@ -38,7 +39,7 @@ main() { fi if [ $# -eq 0 ]; then - printf "Error: No arguments provided\nusage: tohex [-lmnp] number1 number2 ...\n" >&2 + printf "Error: No arguments provided\n%s\n" "$USAGE" >&2 return 2 fi @@ -51,7 +52,7 @@ main() { m) m=1; ;; n) n=1; ;; p) p="0x" ;; - *) printf "usage: tohex [-lmnp] number1 number2 ...\n" >&2 ; return 2 ;; + *) printf "%s\n" "$USAGE" >&2 ; return 2 ;; esac done