You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: plugins/available/extract.plugin.bash
+17-12
Original file line number
Diff line number
Diff line change
@@ -3,8 +3,8 @@ about-plugin 'one command to extract them all...'
3
3
4
4
# extract file(s) from compressed status
5
5
functionextract() {
6
-
local opt
7
-
localOPTIND=1
6
+
local opt OPTIND=1 verbose
7
+
localfilename filedirname targetdirname
8
8
whilegetopts"hv" opt;do
9
9
case"$opt"in
10
10
h)
@@ -27,32 +27,37 @@ EOU
27
27
done
28
28
shift$((OPTIND -1))
29
29
30
-
[ $#-eq 0 ] && extract -h &&return 1
31
-
while [ $#-gt 0 ];do
32
-
if [[ !-f"$1" ]];then
30
+
if [[ $#-eq 0 ]];then
31
+
extract -h
32
+
return 1
33
+
fi
34
+
35
+
while [[ $#-gt 0 ]];do
36
+
if [[ !-f"${1:-}" ]];then
33
37
echo"extract: '$1' is not a valid file">&2
34
38
shift
35
39
continue
36
40
fi
37
41
38
-
local -r filename=$(basename -- $1)
39
-
local -r filedirname=$(dirname -- $1)
40
-
local targetdirname=$(sed 's/\(\.tar\.bz2$\|\.tbz$\|\.tbz2$\|\.tar\.gz$\|\.tgz$\|\.tar$\|\.tar\.xz$\|\.txz$\|\.tar\.Z$\|\.7z$\|\.nupkg$\|\.zip$\|\.war$\|\.jar$\)//g'<<<$filename)
41
-
if [ "$filename"="$targetdirname" ];then
42
+
local -r filename=$(basename -- "$1")
43
+
local -r filedirname=$(dirname -- "$1")
44
+
# shellcheck disable=SC2001 # we don't depend on `extglob`...
0 commit comments