From 88408e8bc25518a050d0de0565aadee65c5abc2a Mon Sep 17 00:00:00 2001 From: nasenatmer Date: Tue, 14 May 2013 22:06:24 +0100 Subject: [PATCH] Add rar command to archive module This addition tries to use the rar command if unrar is not found. Signed-off-by: Sorin Ionescu --- modules/archive/README.md | 2 +- modules/archive/functions/extract | 4 +++- modules/archive/functions/ls-archive | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/modules/archive/README.md b/modules/archive/README.md index 398d003..37dbf12 100644 --- a/modules/archive/README.md +++ b/modules/archive/README.md @@ -26,7 +26,7 @@ installed: - *.lzma* requires `unlzma`. - *.Z* requires `uncompress`. - *.zip* requires `unzip`. - - *.rar* requires `unrar`. + - *.rar* requires `unrar` or `rar`. - *.7z* requires `7za`. - *.deb* requires `ar`, `tar`. diff --git a/modules/archive/functions/extract b/modules/archive/functions/extract index af7ed25..70fac4d 100644 --- a/modules/archive/functions/extract +++ b/modules/archive/functions/extract @@ -53,7 +53,9 @@ while (( $# > 0 )); do (*.lzma) unlzma "$1" ;; (*.Z) uncompress "$1" ;; (*.zip) unzip "$1" -d $extract_dir ;; - (*.rar) unrar e -ad "$1" ;; + (*.rar) unrar &> /dev/null \ + && unrar e -ad "$1" \ + || rar e -ad "$1" ;; (*.7z) 7za x "$1" ;; (*.deb) mkdir -p "$extract_dir/control" diff --git a/modules/archive/functions/ls-archive b/modules/archive/functions/ls-archive index e8727fa..99ebde6 100644 --- a/modules/archive/functions/ls-archive +++ b/modules/archive/functions/ls-archive @@ -41,7 +41,9 @@ while (( $# > 0 )); do || lzcat "$1" | tar x${verbose:+v}f - ;; (*.tar) tar t${verbose:+v}f "$1" ;; (*.zip) unzip -l${verbose:+v} "$1" ;; - (*.rar) unrar ${${verbose:+v}:-l} "$1" ;; + (*.rar) unrar &> /dev/null \ + && unrar ${${verbose:+v}:-l} "$1" \ + || rar ${${verbose:+v}:-l} "$1" ;; (*.7z) 7za l "$1" ;; (*) print "$0: cannot list: $1" >&2