Browse Source

[archivers] shellcheck

master
Matteo Cypriani 1 year 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 @@

## Verify program name ##

PROGRAM="`basename $0`"
PROGRAM="$(basename "$0")"

if [ "$PROGRAM" = "lz" ] ; then
ACTION="t"
elif [ "$PROGRAM" = "uz" ] ; then
ACTION="x"
else
echo '$0 = "'"$0"' (not "lz" nor "uz")!' >&2
printf 'Error! Program name is "%s" (not "lz" nor "uz")!\n' "$PROGRAM" >&2
exit 1
fi

@@ -49,38 +49,38 @@ for F in "$@" ; do
fi

# Simple Tar archive
if [ "`basename "$F" .tar`" != "$F" ] ; then
if [ "$(basename "$F" .tar)" != "$F" ] ; then
FORMAT=""

# GZipped Tar
elif [ "`basename "$F" .tar.gz`" != "$F" \
-o "`basename "$F" .tgz`" != "$F" ] ; then
FORMAT="--gzip"
# GZipped Tar
elif [ "$(basename "$F" .tar.gz)" != "$F" ] || \
[ "$(basename "$F" .tgz)" != "$F" ] ; then
FORMAT="--gzip"

# BZipped Tar
elif [ "`basename "$F" .tar.bz2`" != "$F" \
-o "`basename "$F" .tbz`" != "$F" \
-o "`basename "$F" .tb2`" != "$F" ] ; then
FORMAT="--bzip"
elif [ "$(basename "$F" .tar.bz2)" != "$F" ] || \
[ "$(basename "$F" .tbz)" != "$F" ] || \
[ "$(basename "$F" .tb2)" != "$F" ] ; then
FORMAT="--bzip"

# XZipped Tar
elif [ "`basename "$F" .tar.xz`" != "$F" \
-o "`basename "$F" .txz`" != "$F" ] ; then
FORMAT="--xz"
elif [ "$(basename "$F" .tar.xz)" != "$F" ] || \
[ "$(basename "$F" .txz)" != "$F" ] ; then
FORMAT="--xz"

# Compressed Tar
elif [ "`basename "$F" .tar.Z`" != "$F" \
-o "`basename "$F" .taz`" != "$F" ] ; then
FORMAT="--compress"
elif [ "$(basename "$F" .tar.Z)" != "$F" ] || \
[ "$(basename "$F" .taz)" != "$F" ] ; then
FORMAT="--compress"

# LZMA compressed Tar
elif [ "`basename "$F" .tar.lzma`" != "$F" \
-o "`basename "$F" .tlz`" != "$F" ] ; then
FORMAT="--lzma"
elif [ "$(basename "$F" .tar.lzma)" != "$F" ] || \
[ "$(basename "$F" .tlz)" != "$F" ] ; then
FORMAT="--lzma"

# Unknown extension
else
echo "Extension of file « $F » unknown! (skipping)" >&2
printf 'Extension of file "%s" unknown! (skipping)\n' "$F" >&2
continue
fi


+ 1
- 2
archivers/xzize.sh View File

@@ -28,7 +28,6 @@ COMPRESSION_LEVEL=

test_extension()
{
local - FILE EXTENSION BASE
FILE="$1"
EXTENSION="$2"
NEWEXTENSION=xz
@@ -36,7 +35,7 @@ test_extension()
NEWEXTENSION="$3"
fi

BASE="`basename "$FILE" ."$EXTENSION"`"
BASE="$(basename "$FILE" ."$EXTENSION")"
if [ "$BASE" != "$FILE" ] ; then
DEST="$BASE".$NEWEXTENSION
return 0

Loading…
Cancel
Save