* znew.in: Change -K option to imply -t, do not use compress(1).
* znew.1: Document it.
* tests/znew-k: New test.
* Makefile.am (TESTS): Add it.
tests/memcpy-abuse \
tests/trailing-nul \
tests/zdiff \
- tests/zgrep-f
+ tests/zgrep-f \
+ tests/znew-k
EXTRA_DIST += $(TESTS)
--- /dev/null
+#!/bin/sh
+# Check that znew -K works without compress(1).
+
+# Copyright (C) 2010 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# limit so don't run it by default.
+
+if test "$VERBOSE" = yes; then
+ set -x
+ gzip --version
+fi
+
+: ${srcdir=.}
+. "$srcdir/tests/init.sh"; path_prepend_ "`pwd`"
+
+cat <<'EOF' >compress || framework_failure
+#!/bin/sh
+echo >&2 'compress have been called'
+exit 1
+EOF
+chmod +x compress || framework_failure
+
+printf '%1012977s' ' ' | gzip -c >znew-k.Z || framework_failure
+
+fail=0
+
+znew -K znew-k.Z || fail=1
+test -f znew-k.Z || fail=1
+
+Exit $fail
Use pipes for the conversion to reduce disk space usage.
.TP
.B \-K
-Keep a .Z file when it is smaller than the .gz file
+Keep a .Z file when it is smaller than the .gz file; implies
+.BR -t .
.SH "SEE ALSO"
gzip(1), zmore(1), zdiff(1), zgrep(1), zforce(1), gzexe(1), compress(1)
.SH BUGS
-v Verbose; display name and statistics for each file compressed.
-9 Use the slowest compression method (optimal compression).
-P Use pipes for the conversion to reduce disk space usage.
- -K Keep a .Z file when it is smaller than the .gz file.
+ -K Keep a .Z file when it is smaller than the .gz file; implies -t.
--help display this help and exit
--version output version information and exit
*t*) check=1; opt=`echo "$opt" | sed 's/t//g'`
esac
case "$opt" in
- *K*) keep=1; opt=`echo "$opt" | sed 's/K//g'`
+ *K*) keep=1; check=1; opt=`echo "$opt" | sed 's/K//g'`
esac
case "$opt" in
*P*) pipe=1; opt=`echo "$opt" | sed 's/P//g'`
`expr \( $new + $block - 1 \) / $block`; then
if test $pipe -eq 1; then
rm -f "$n$ext"
- elif test $check -eq 1; then
- mv "$n.$$" "$n.Z" && rm -f "$n$ext"
else
- gzip -d "$n$ext" && compress "$n" && rm -f "$n$ext"
+ mv "$n.$$" "$n.Z" && rm -f "$n$ext"
fi
echo "$n.Z smaller than $n$ext -- unchanged"