diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2017-11-12 23:02:02 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2017-11-12 23:11:07 -0800 |
commit | f55f2be13c2f1afa8d76daadabb3b24c7fe34743 (patch) | |
tree | 21a93ae6a3626641d93fb8271ae97c4992702824 /gzexe.in | |
parent | b1d08ed0e26f0a8c81910c5950275d28ce06bd9c (diff) | |
download | gzip-f55f2be13c2f1afa8d76daadabb3b24c7fe34743.tar.gz |
maint: script diagnostics status cleanup
Problem reported by Bruno Haible (Bug#29266#20).
* NEWS: Mention this.
* gunzip.in, gzexe.in, zcat.in, zcmp.in, zdiff.in, zforce.in:
* zgrep.in, zless.in, zmore.in, znew.in:
Use printf instead of echo if the argument might contain ‘\’, at
least in theory. Don’t assume printf exits with status 1 on
failure; it might be some other positive status.
* gzexe.in: Use printf consistently instead of echo, and
proscribe it instead of echo.
Diffstat (limited to 'gzexe.in')
-rw-r--r-- | gzexe.in | 40 |
1 files changed, 20 insertions, 20 deletions
@@ -59,15 +59,15 @@ res=0 while :; do case $1 in -d) decomp=1; shift;; - --h*) exec echo "$usage";; - --v*) exec echo "$version";; + --h*) printf '%s\n' "$usage" || exit 1; exit;; + --v*) printf '%s\n' "$version" || exit 1; exit;; --) shift; break;; *) break;; esac done if test $# -eq 0; then - echo >&2 "$0: missing operand + printf >&2 '%s\n' "$0: missing operand Try \`$0 --help' for more information." exit 1 fi @@ -87,29 +87,29 @@ for i do esac if test ! -f "$file" || test ! -r "$file"; then res=$? - echo >&2 "$0: $i is not a readable regular file" + printf >&2 '%s\n' "$0: $i is not a readable regular file" continue fi if test $decomp -eq 0; then if sed -e 1d -e 2q "$file" | grep "^skip=[0-9][0-9]*$" >/dev/null; then - echo >&2 "$0: $i is already gzexe'd" + printf >&2 '%s\n' "$0: $i is already gzexe'd" continue fi fi if test -u "$file"; then - echo >&2 "$0: $i has setuid permission, unchanged" + printf >&2 '%s\n' "$0: $i has setuid permission, unchanged" continue fi if test -g "$file"; then - echo >&2 "$0: $i has setgid permission, unchanged" + printf >&2 '%s\n' "$0: $i has setgid permission, unchanged" continue fi case /$file in */basename | */bash | */cat | */chmod | */cp | \ - */dirname | */echo | */expr | */gzip | \ - */ln | */mkdir | */mktemp | */mv | */rm | \ + */dirname | */expr | */gzip | \ + */ln | */mkdir | */mktemp | */mv | */printf | */rm | \ */sed | */sh | */sleep | */test | */tail) - echo >&2 "$0: $i might depend on itself"; continue;; + printf >&2 '%s\n' "$0: $i might depend on itself"; continue;; esac dir=`dirname "$file"` || dir=$TMPDIR @@ -125,7 +125,7 @@ for i do tmp=$dir/gzexe$$ fi && { cp -p "$file" "$tmp" 2>/dev/null || cp "$file" "$tmp"; } || { res=$? - echo >&2 "$0: cannot copy $file" + printf >&2 '%s\n' "$0: cannot copy $file" continue } if test -w "$tmp"; then @@ -134,7 +134,7 @@ for i do writable=0 chmod u+w "$tmp" || { res=$? - echo >&2 "$0: cannot chmod $tmp" + printf >&2 '%s\n' "$0: cannot chmod $tmp" continue } fi @@ -170,7 +170,7 @@ case $0 in */*) gztmp=$gztmpdir/`basename "$0"`;; esac || { (exit 127); exit 127; } -case `echo X | tail -n +1 2>/dev/null` in +case `printf 'X\n' | tail -n +1 2>/dev/null` in X) tail_n=-n;; *) tail_n=;; esac @@ -180,13 +180,13 @@ if tail $tail_n +$skip <"$0" | gzip -cd > "$gztmp"; then (sleep 5; rm -fr "$gztmpdir") 2>/dev/null & "$gztmp" ${1+"$@"}; res=$? else - echo >&2 "Cannot decompress $0" + printf >&2 '%s\n' "Cannot decompress $0" (exit 127); res=127 fi; exit $res EOF gzip -cv9 "$file") > "$tmp" || { res=$? - echo >&2 "$0: compression not possible for $i, file unchanged." + printf >&2 '%s\n' "$0: compression not possible for $i, file unchanged." continue } @@ -198,29 +198,29 @@ EOF skip=[0-9] | skip=[0-9][0-9] | skip=[0-9][0-9][0-9]) eval "$skip_line";; esac - case `echo X | tail -n +1 2>/dev/null` in + case `printf 'X\n' | tail -n +1 2>/dev/null` in X) tail_n=-n;; *) tail_n=;; esac tail $tail_n +$skip "$file" | gzip -cd > "$tmp" || { res=$? - echo >&2 "$0: $i probably not in gzexe format, file unchanged." + printf >&2 '%s\n' "$0: $i probably not in gzexe format, file unchanged." continue } fi test $writable -eq 1 || chmod u-w "$tmp" || { res=$? - echo >&2 "$0: $tmp: cannot chmod" + printf >&2 '%s\n' "$0: $tmp: cannot chmod" continue } ln -f "$file" "$file~" || { res=$? - echo >&2 "$0: cannot backup $i as $i~" + printf >&2 '%s\n' "$0: cannot backup $i as $i~" continue } mv -f "$tmp" "$file" || { res=$? - echo >&2 "$0: cannot rename $tmp to $i" + printf >&2 '%s\n' "$0: cannot rename $tmp to $i" continue } tmp= |