[compression_utils] Bug fixes on xzize
xzize: - Fix bug with file names with spaces. - Fix bug when invoking program without arguments. - Handle error when input file is not a regular file instead of delegate to xz. - Add an info message when compressing an uncompressed file. lz: - Info message on stdout instead of stderr when uncompressing.
This commit is contained in:
parent
f7c2f3aec7
commit
93601c6310
|
@ -45,7 +45,7 @@ for F in "$@" ; do
|
||||||
if [ "$ACTION" = "t" ] ; then
|
if [ "$ACTION" = "t" ] ; then
|
||||||
echo "*** Listing « $F » ***" >&2
|
echo "*** Listing « $F » ***" >&2
|
||||||
else
|
else
|
||||||
echo "Extracting « $F »…" >&2
|
echo "Extracting « $F »…"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Simple Tar archive
|
# Simple Tar archive
|
||||||
|
|
|
@ -41,7 +41,7 @@ do_recompress()
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
echo "Recompressing « $SOURCE » to « $DEST »…"
|
echo "Recompressing « $SOURCE » to « $DEST »…"
|
||||||
$ACTION -c $SOURCE | xz -9 >$DEST
|
$ACTION -c "$SOURCE" | xz -9 >"$DEST"
|
||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ do_recompress()
|
||||||
## Verify number of arguments ##
|
## Verify number of arguments ##
|
||||||
|
|
||||||
if [ $# -lt 1 ] ; then
|
if [ $# -lt 1 ] ; then
|
||||||
echo "$PROGRAM requires at least one argument!" >&2
|
echo "$0 requires at least one argument!" >&2
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -57,6 +57,11 @@ fi
|
||||||
## Process files ##
|
## Process files ##
|
||||||
|
|
||||||
for SOURCE in "$@" ; do
|
for SOURCE in "$@" ; do
|
||||||
|
# Regular file?
|
||||||
|
if [ ! -f "$SOURCE" ] ; then
|
||||||
|
echo "Skipping source file « $SOURCE »: is not a regular file!" >&2
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
# GZip
|
# GZip
|
||||||
test_extension "$SOURCE" gz
|
test_extension "$SOURCE" gz
|
||||||
|
@ -92,11 +97,12 @@ for SOURCE in "$@" ; do
|
||||||
|
|
||||||
# XZ
|
# XZ
|
||||||
if test_extension "$SOURCE" xz ; then
|
if test_extension "$SOURCE" xz ; then
|
||||||
echo "Skipping source file « $DEST »: it has already .xz suffix!" >&2
|
echo "Skipping source file « $DEST »: has already .xz suffix!" >&2
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Uncompressed file: fall back to simple compression
|
# Uncompressed file: fall back to simple compression
|
||||||
|
echo "Compressing « $SOURCE » to xz…"
|
||||||
xz -9 "$SOURCE"
|
xz -9 "$SOURCE"
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in New Issue