1
0
Fork 0
mirror of https://git.tukaani.org/xz.git synced 2024-04-04 12:36:23 +02:00

Scripts: Use printf instead of echo in a few places.

It's a good habbit as echo has some portability corner cases
when the string contents can be anything.
This commit is contained in:
Lasse Collin 2022-07-18 19:18:48 +03:00
parent 0e222bf7d7
commit 4a61867a87
4 changed files with 11 additions and 11 deletions

View file

@ -51,7 +51,7 @@ escape='
while :; do
case $1 in
--h*) printf '%s\n' "$usage" || exit 2; exit;;
--v*) echo "$version" || exit 2; exit;;
--v*) printf '%s\n' "$version" || exit 2; exit;;
--) shift; break;;
-*\'*) cmp="$cmp '"`printf '%sX\n' "$1" | sed "$escape"`;;
-?*) cmp="$cmp '$1'";;
@ -83,7 +83,7 @@ if test $# -eq 1; then
*[-.]zst | *.tzst)
xz1='zstd -q';;
*)
echo >&2 "$0: $1: Unknown compressed file name suffix"
printf '%s\n' "$0: $1: Unknown compressed file name suffix" >&2
exit 2;;
esac
case $1 in
@ -193,7 +193,7 @@ elif test $# -eq 2; then
esac;;
esac
else
echo >&2 "$0: Invalid number of operands; try \`${0##*/} --help' for help"
printf '%s\n' "$0: Invalid number of operands; try \`${0##*/} --help' for help" >&2
exit 2
fi

View file

@ -116,7 +116,7 @@ while test $# -ne 0; do
(-[ef]* | --file | --file=* | --reg*)
have_pat=1;;
(--h | --he | --hel | --help)
echo "$usage" || exit 2
printf '%s\n' "$usage" || exit 2
exit;;
(-H | --wi | --wit | --with | --with- | --with-f | --with-fi \
| --with-fil | --with-file | --with-filen | --with-filena | --with-filenam \
@ -132,7 +132,7 @@ while test $# -ne 0; do
(-h | --no-f*)
no_filename=1;;
(-V | --v | --ve | --ver | --vers | --versi | --versio | --version)
echo "$version" || exit 2
printf '%s\n' "$version" || exit 2
exit;;
esac

View file

@ -33,8 +33,8 @@ Options are the same as for 'less'.
Report bugs to <@PACKAGE_BUGREPORT@>."
case $1 in
--help) echo "$usage" || exit 2; exit;;
--version) echo "$version" || exit 2; exit;;
--help) printf '%s\n' "$usage" || exit 2; exit;;
--version) printf '%s\n' "$version" || exit 2; exit;;
esac
if test "${LESSMETACHARS+set}" != set; then

View file

@ -31,8 +31,8 @@ Like 'more', but operate on the uncompressed contents of xz compressed FILEs.
Report bugs to <@PACKAGE_BUGREPORT@>."
case $1 in
--help) echo "$usage" || exit 2; exit;;
--version) echo "$version" || exit 2; exit;;
--help) printf '%s\n' "$usage" || exit 2; exit;;
--version) printf '%s\n' "$version" || exit 2; exit;;
esac
oldtty=`stty -g 2>/dev/null`
@ -50,7 +50,7 @@ fi
if test $# = 0; then
if test -t 0; then
echo "$usage"; exit 1
printf '%s\n' "$usage"; exit 1
else
$xz -cdfq | eval "${PAGER:-more}"
fi
@ -69,7 +69,7 @@ else
esac
fi
if test "$ANS" != 's'; then
echo "------> $FILE <------"
printf '%s\n' "------> $FILE <------"
$xz -cdfq -- "$FILE" | eval "${PAGER:-more}"
fi
if test -t 1; then