Browse code

Handle tar.xz and tar.lzma better (credit: @gwjo).

Sorin Ionescu authored on 18/04/2011 at 03:17:48
Showing 1 changed files
... ...
@@ -2,7 +2,7 @@
2 2
 #          FILE:  extract.plugin.zsh
3 3
 #   DESCRIPTION:  oh-my-zsh plugin file.
4 4
 #        AUTHOR:  Sorin Ionescu (sorin.ionescu@gmail.com)
5
-#       VERSION:  1.0.0
5
+#       VERSION:  1.0.1
6 6
 # ------------------------------------------------------------------------------
7 7
 
8 8
 
... ...
@@ -40,10 +40,12 @@ function extract() {
40 40
     case "$1" in
41 41
       (*.tar.gz|*.tgz) tar xvzf "$1" ;;
42 42
       (*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$1" ;;
43
-      (*.tar.xz|*.txz) tar xvJf "$1" ;;
44
-      # (*.tar.xz|*.txz) xzcat "$1" | tar xvf - ;;
45
-      (*.tar.lzma|*.tlz) tar --lzma -xvf "$1" ;;
46
-      # (*.tar.lzma|*.tlz) lzcat "$1" | tar xvf - ;;
43
+      (*.tar.xz|*.txz) tar --xz --help &> /dev/null \
44
+        && tar --xz -xvf "$1" \
45
+        || xzcat "$1" | tar xvf - ;;
46
+      (*.tar.zma|*.tlz) tar --lzma --help &> /dev/null \
47
+        && tar --lzma -xvf "$1" \
48
+        || lzcat "$1" | tar xvf - ;;
47 49
       (*.tar) tar xvf "$1" ;;
48 50
       (*.gz) gunzip "$1" ;;
49 51
       (*.bz2) bunzip2 "$1" ;;