Browse Source

[archivers] shellcheck

Matteo Cypriani 9 months ago
parent
commit
e28443a12e
2 changed files with 22 additions and 23 deletions
  1. 21
    21
      archivers/lz.sh
  2. 1
    2
      archivers/xzize.sh

+ 21
- 21
archivers/lz.sh View File

@@ -19,14 +19,14 @@
19 19
 
20 20
 ## Verify program name ##
21 21
 
22
-PROGRAM="`basename $0`"
22
+PROGRAM="$(basename "$0")"
23 23
 
24 24
 if [ "$PROGRAM" = "lz" ] ; then
25 25
     ACTION="t"
26 26
 elif [ "$PROGRAM" = "uz" ] ; then
27 27
     ACTION="x"
28 28
 else
29
-    echo '$0 = "'"$0"' (not "lz" nor "uz")!' >&2
29
+    printf 'Error! Program name is "%s" (not "lz" nor "uz")!\n' "$PROGRAM" >&2
30 30
     exit 1
31 31
 fi
32 32
 
@@ -49,38 +49,38 @@ for F in "$@" ; do
49 49
     fi
50 50
 
51 51
     # Simple Tar archive
52
-    if [ "`basename "$F" .tar`" != "$F" ] ; then
52
+    if [ "$(basename "$F" .tar)" != "$F" ] ; then
53 53
         FORMAT=""
54 54
 
55
-        # GZipped Tar
56
-    elif [ "`basename "$F" .tar.gz`" != "$F" \
57
-        -o "`basename "$F" .tgz`" != "$F" ] ; then
58
-    FORMAT="--gzip"
55
+    # GZipped Tar
56
+    elif [ "$(basename "$F" .tar.gz)" != "$F" ] || \
57
+         [ "$(basename "$F" .tgz)" != "$F" ] ; then
58
+        FORMAT="--gzip"
59 59
 
60 60
     # BZipped Tar
61
-    elif [ "`basename "$F" .tar.bz2`" != "$F" \
62
-        -o "`basename "$F" .tbz`" != "$F" \
63
-        -o "`basename "$F" .tb2`" != "$F" ] ; then
64
-    FORMAT="--bzip"
61
+    elif [ "$(basename "$F" .tar.bz2)" != "$F" ] || \
62
+         [ "$(basename "$F" .tbz)" != "$F" ] || \
63
+         [ "$(basename "$F" .tb2)" != "$F" ] ; then
64
+        FORMAT="--bzip"
65 65
 
66 66
     # XZipped Tar
67
-    elif [ "`basename "$F" .tar.xz`" != "$F" \
68
-        -o "`basename "$F" .txz`" != "$F" ] ; then
69
-    FORMAT="--xz"
67
+    elif [ "$(basename "$F" .tar.xz)" != "$F" ] || \
68
+         [ "$(basename "$F" .txz)" != "$F" ] ; then
69
+        FORMAT="--xz"
70 70
 
71 71
     # Compressed Tar
72
-    elif [ "`basename "$F" .tar.Z`" != "$F" \
73
-        -o "`basename "$F" .taz`" != "$F" ] ; then
74
-    FORMAT="--compress"
72
+    elif [ "$(basename "$F" .tar.Z)" != "$F" ] || \
73
+         [ "$(basename "$F" .taz)" != "$F" ] ; then
74
+        FORMAT="--compress"
75 75
 
76 76
     # LZMA compressed Tar
77
-    elif [ "`basename "$F" .tar.lzma`" != "$F" \
78
-        -o "`basename "$F" .tlz`" != "$F" ] ; then
79
-    FORMAT="--lzma"
77
+    elif [ "$(basename "$F" .tar.lzma)" != "$F" ] || \
78
+         [ "$(basename "$F" .tlz)" != "$F" ] ; then
79
+        FORMAT="--lzma"
80 80
 
81 81
     # Unknown extension
82 82
     else
83
-        echo "Extension of file « $F » unknown! (skipping)" >&2
83
+        printf 'Extension of file "%s" unknown! (skipping)\n' "$F" >&2
84 84
         continue
85 85
     fi
86 86
 

+ 1
- 2
archivers/xzize.sh View File

@@ -28,7 +28,6 @@ COMPRESSION_LEVEL=
28 28
 
29 29
 test_extension()
30 30
 {
31
-	local - FILE EXTENSION BASE
32 31
 	FILE="$1"
33 32
 	EXTENSION="$2"
34 33
 	NEWEXTENSION=xz
@@ -36,7 +35,7 @@ test_extension()
36 35
 		NEWEXTENSION="$3"
37 36
 	fi
38 37
 
39
-	BASE="`basename "$FILE" ."$EXTENSION"`"
38
+	BASE="$(basename "$FILE" ."$EXTENSION")"
40 39
 	if [ "$BASE" != "$FILE" ] ; then
41 40
 		DEST="$BASE".$NEWEXTENSION
42 41
 		return 0

Loading…
Cancel
Save