4 PATH="/mingw/bin:$PATH"; export PATH
14 # block is the disk block size (best guess, need not be exact)
16 warn="(does not preserve modes and timestamp)"
20 if test -z "`(${CPMOD-cpmod} $tmp.1 $tmp.2) 2>&1`"; then
25 if test -z "$cpmod" && ${TOUCH-touch} -r $tmp.1 $tmp.2 2>/dev/null; then
26 cpmod="${TOUCH-touch}"
28 warn="(does not preserve file modes)"
31 # check if GZIP env. variable uses -S or --suffix
33 ext=`echo $tmp.1* | sed "s|$tmp.1||"`
35 if test -z "$ext"; then
36 echo znew: error determining gzip extension
39 if test "$ext" = ".Z"; then
40 echo znew: cannot use .Z as gzip extension.
47 -*) opt="$opt $arg"; shift;;
52 if test $# -eq 0; then
53 echo "recompress .Z files into $ext (gzip) files"
54 echo usage: `echo $0 | sed 's,^.*/,,'` "[-tv9KP]" file.Z...
55 echo " -t tests the new files before deleting originals"
57 echo " -9 use the slowest compression method (optimal compression)"
58 echo " -K keep a .Z file when it is smaller than the $ext file"
59 echo " -P use pipes for the conversion $warn"
63 opt=`echo "$opt" | sed -e 's/ //g' -e 's/-//g'`
65 *t*) check=1; opt=`echo "$opt" | sed 's/t//g'`
68 *K*) keep=1; opt=`echo "$opt" | sed 's/K//g'`
71 *P*) pipe=1; opt=`echo "$opt" | sed 's/P//g'`
73 if test -n "$opt"; then
78 n=`echo $i | sed 's/.Z$//'`
79 if test ! -f "$n.Z" ; then
83 test $keep -eq 1 && old=`wc -c < "$n.Z"`
84 if test $pipe -eq 1; then
85 if gzip -d < "$n.Z" | gzip $opt > "$n$ext"; then
86 # Copy file attributes from old file to new one, if possible.
87 test -n "$cpmod" && $cpmod $cpmodarg "$n.Z" "$n$ext" 2> /dev/null
89 echo error while recompressing $n.Z
93 if test $check -eq 1; then
94 if cp -p "$n.Z" "$n.$$" 2> /dev/null || cp "$n.Z" "$n.$$"; then
97 echo cannot backup "$n.Z"
101 if gzip -d "$n.Z"; then
104 test $check -eq 1 && mv "$n.$$" "$n.Z"
105 echo error while uncompressing $n.Z
108 if gzip $opt "$n"; then
111 if test $check -eq 1; then
112 mv "$n.$$" "$n.Z" && rm -f "$n"
113 echo error while recompressing $n
115 # compress $n (might be dangerous if disk full)
116 echo error while recompressing $n, left uncompressed
121 test $keep -eq 1 && new=`wc -c < "$n$ext"`
122 if test $keep -eq 1 -a `expr \( $old + $block - 1 \) / $block` -lt \
123 `expr \( $new + $block - 1 \) / $block`; then
124 if test $pipe -eq 1; then
126 elif test $check -eq 1; then
127 mv "$n.$$" "$n.Z" && rm -f "$n$ext"
129 gzip -d "$n$ext" && compress "$n" && rm -f "$n$ext"
131 echo "$n.Z smaller than $n$ext -- unchanged"
133 elif test $check -eq 1; then
134 if gzip -t "$n$ext" ; then
137 test $pipe -eq 0 && mv "$n.$$" "$n.Z"
139 echo error while testing $n$ext, $n.Z unchanged
142 elif test $pipe -eq 1; then