wok-next rev 8114
Fix: lzma wrapper in xz package should now display usage correctly
author | Antoine Bodin <gokhlayeh@slitaz.org> |
---|---|
date | Sun Jan 23 22:57:43 2011 +0100 (2011-01-23) |
parents | 99603513ae10 |
children | 94e37d5bb0dc |
files | xz/stuff/lzma |
line diff
1.1 --- a/xz/stuff/lzma Sun Jan 23 16:00:57 2011 +0000 1.2 +++ b/xz/stuff/lzma Sun Jan 23 22:57:43 2011 +0100 1.3 @@ -5,6 +5,7 @@ 1.4 1.5 usage() 1.6 { 1.7 + status=$? 1.8 cat 1>&2 <<EOT 1.9 Usage: LZMA <e|d> inputFile outputFile [<switches>...] 1.10 e: encode file 1.11 @@ -22,7 +23,12 @@ 1.12 -si: read data from stdin 1.13 -so: write data to stdout 1.14 EOT 1.15 - exit 0 1.16 + if [ "$1" = error ]; then 1.17 + echo -e "\nError" 1.18 + exit $status 1.19 + else 1.20 + exit 0 1.21 + fi 1.22 } 1.23 1.24 # Get lzma_alone arg 1.25 @@ -66,7 +72,7 @@ 1.26 shift 1.27 done 1.28 for i in $files; do 1.29 - xz $args $i || exit 1.30 + xz $args $i || usage error 1.31 [ "lzma" == "$suffix" ] || mv ${i%.*}.lzma ${i%.*}.$suffix 1.32 done 1.33 exit 1.34 @@ -77,12 +83,17 @@ 1.35 *lzcat) lzma_utils -c -d $@ ;; 1.36 esac 1.37 1.38 +# First look if help is needed. 1.39 +[ "$1" ] || usage 1.40 +case "$1" in 1.41 + --version|-V|--help|-h|-\?|'') usage;; 1.42 +esac 1.43 + 1.44 # lzma_utils or lzma_alone ? 1.45 [ -n "$3" ] || lzma_utils $@ 1.46 case "$1" in 1.47 d) args="-d";; 1.48 e) args="-z";; 1.49 ---version|-V|--help|-h|-\?|'') usage;; 1.50 *) lzma_utils $@;; 1.51 esac 1.52 1.53 @@ -101,13 +112,12 @@ 1.54 extra="" 1.55 mode="lzma1=mode=normal" 1.56 while [ -n "$2" ]; do 1.57 - getarg "$2" || usage 1.58 + getarg "$2" || usage error 1.59 shift 1.60 done 1.61 1.62 # fake lzma_alone (-eos -mt1) 1.63 -eval xz $args --format=lzma --$mode$extra --stdout $input $output 1.64 -status=$? 1.65 +eval xz $args --format=lzma --$mode$extra --stdout $input $output || usage error 1.66 if [ -n "$input" -a -n "$output" ]; then 1.67 size=$(stat -c "%s" ${input#< }) 1.68 ascii="00000 " 1.69 @@ -118,4 +128,4 @@ 1.70 echo "$ascii | .." | hexdump -R | \ 1.71 dd of=${output#> } seek=5 bs=1 conv=notrunc 2> /dev/null 1.72 fi 1.73 -exit $status 1.74 +exit 0