# HG changeset patch # User Antoine Bodin # Date 1295819863 -3600 # Node ID b07e53f0d08e8fa0dc513c77113150bb5bfa42b5 # Parent 99603513ae1092f0df50751625536b1c04f37182 Fix: lzma wrapper in xz package should now display usage correctly diff -r 99603513ae10 -r b07e53f0d08e xz/stuff/lzma --- a/xz/stuff/lzma Sun Jan 23 16:00:57 2011 +0000 +++ b/xz/stuff/lzma Sun Jan 23 22:57:43 2011 +0100 @@ -5,6 +5,7 @@ usage() { + status=$? cat 1>&2 < inputFile outputFile [...] e: encode file @@ -22,7 +23,12 @@ -si: read data from stdin -so: write data to stdout EOT - exit 0 + if [ "$1" = error ]; then + echo -e "\nError" + exit $status + else + exit 0 + fi } # Get lzma_alone arg @@ -66,7 +72,7 @@ shift done for i in $files; do - xz $args $i || exit + xz $args $i || usage error [ "lzma" == "$suffix" ] || mv ${i%.*}.lzma ${i%.*}.$suffix done exit @@ -77,12 +83,17 @@ *lzcat) lzma_utils -c -d $@ ;; esac +# First look if help is needed. +[ "$1" ] || usage +case "$1" in + --version|-V|--help|-h|-\?|'') usage;; +esac + # lzma_utils or lzma_alone ? [ -n "$3" ] || lzma_utils $@ case "$1" in d) args="-d";; e) args="-z";; ---version|-V|--help|-h|-\?|'') usage;; *) lzma_utils $@;; esac @@ -101,13 +112,12 @@ extra="" mode="lzma1=mode=normal" while [ -n "$2" ]; do - getarg "$2" || usage + getarg "$2" || usage error shift done # fake lzma_alone (-eos -mt1) -eval xz $args --format=lzma --$mode$extra --stdout $input $output -status=$? +eval xz $args --format=lzma --$mode$extra --stdout $input $output || usage error if [ -n "$input" -a -n "$output" ]; then size=$(stat -c "%s" ${input#< }) ascii="00000 " @@ -118,4 +128,4 @@ echo "$ascii | .." | hexdump -R | \ dd of=${output#> } seek=5 bs=1 conv=notrunc 2> /dev/null fi -exit $status +exit 0