diff options
author | Mike Crute <mike@crute.us> | 2020-04-16 11:11:21 -0700 |
---|---|---|
committer | Mike Crute <mike@crute.us> | 2020-04-16 11:11:21 -0700 |
commit | c97908cca1002c078d6b2002f9f62ee9ce882b81 (patch) | |
tree | 2fc8e574d15b899718217835486df680d4d6b556 /.bashrc | |
parent | 0fd8b3677a812b557a92877c2d8ca0c4004183fc (diff) | |
download | dotfiles-c97908cca1002c078d6b2002f9f62ee9ce882b81.tar.bz2 dotfiles-c97908cca1002c078d6b2002f9f62ee9ce882b81.tar.xz dotfiles-c97908cca1002c078d6b2002f9f62ee9ce882b81.zip |
bash: untar unpacks rar files
Diffstat (limited to '.bashrc')
-rw-r--r-- | .bashrc | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -644,14 +644,15 @@ func_export add_ssh_keys | |||
644 | # Try to detect (tar|zip)file type and unpack accordingly | 644 | # Try to detect (tar|zip)file type and unpack accordingly |
645 | function untar | 645 | function untar |
646 | { | 646 | { |
647 | local file_type=`file $1 | awk '{ print $2 }'` | 647 | local file_type=`file "$1" | awk -F: '{ gsub(/^ +/, "", $2); split($2, p, " "); print p[1] }'` |
648 | 648 | ||
649 | case "$file_type" in | 649 | case "$file_type" in |
650 | "POSIX") tar -xvf $1 ;; | 650 | "POSIX") tar -xvf "$1" ;; |
651 | "bzip2") tar -xvjf $1 ;; | 651 | "bzip2") tar -xvjf "$1" ;; |
652 | "gzip") tar -xvzf $1 ;; | 652 | "gzip") tar -xvzf "$1" ;; |
653 | "XZ") tar -xvJf $1 ;; | 653 | "XZ") tar -xvJf "$1" ;; |
654 | "Zip") unzip $1 ;; | 654 | "Zip") unzip "$1" ;; |
655 | "RAR") unrar x "$1" ;; | ||
655 | 656 | ||
656 | *) echo "Unable to determine type of tarball." ;; | 657 | *) echo "Unable to determine type of tarball." ;; |
657 | esac | 658 | esac |