1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
diff --git a/configure b/configure
index cbd34af..5df4a31 100755
--- a/configure
+++ b/configure
@@ -405,8 +405,7 @@ LESS_ADVANCED_PREPROCESSOR N # always interpret textlike files (html, ...)
# compression programs
bzip2 Y # include bzip2 and unzip code, it is fairly essential
unzip Y
-rar Y
-unrar Y
+bsdtar Y # bsdtar is the best free as in freedom alternative for rar
lzip N # default for lzma, lzip, xz, 7za should probably be N
lzma Y
xz Y
diff --git a/lesspipe.sh b/lesspipe.sh
index c80c75b..262a47b 100755
--- a/lesspipe.sh
+++ b/lesspipe.sh
@@ -276,12 +276,8 @@ get_cmd () {
cmd=(isrpm "$2" "$file2")
elif [[ "$1" = *Zip* || "$1" = *ZIP* ]] && cmd_exist unzip; then
cmd=(istemp "unzip -avp" "$2" "$file2")
- elif [[ "$1" = *RAR\ archive* ]]; then
- if cmd_exist unrar; then
- cmd=(istemp "unrar p -inul" "$2" "$file2")
- elif cmd_exist rar; then
- cmd=(istemp "rar p -inul" "$2" "$file2")
- fi
+ elif [[ "$1" = *RAR\ archive* ]] && cmd_exist bsdtar; then
+ cmd=(bsdtar xOf "$2" "$file2")
elif [[ "$1" = *7-zip\ archive* || "$1" = *7z\ archive* ]] && cmd_exist 7za; then
cmd=(istemp "7za e -so" "$2" "$file2")
elif [[ "$1" = *7-zip\ archive* || "$1" = *7z\ archive* ]] && cmd_exist 7zr; then
@@ -534,14 +530,9 @@ isfinal() {
elif [[ "$1" = *Zip* || "$1" = *ZIP* ]] && cmd_exist unzip; then
msg "use zip_file${sep}contained_file to view a file in the archive"
istemp "unzip -lv" "$2"
- elif [[ "$1" = *RAR\ archive* ]]; then
- if cmd_exist unrar; then
- msg "use rar_file${sep}contained_file to view a file in the archive"
- istemp "unrar v" "$2"
- elif cmd_exist rar; then
- msg "use rar_file${sep}contained_file to view a file in the archive"
- istemp "rar v" "$2"
- fi
+ elif [[ "$1" = *RAR\ archive* ]] && cmd_exist bsdtar; then
+ msg "use rar_file${sep}contained_file to view a file in the archive"
+ bsdtar tf "$2"
elif [[ "$1" = *7-zip\ archive* || "$1" = *7z\ archive* ]] && cmd_exist 7za; then
typeset res
res=$(istemp "7za l" "$2")
diff --git a/lesspipe.sh.in b/lesspipe.sh.in
index 407bc7d..753f3c5 100755
--- a/lesspipe.sh.in
+++ b/lesspipe.sh.in
@@ -323,17 +323,10 @@ get_cmd () {
elif [[ "$1" = *Zip* || "$1" = *ZIP* ]] && cmd_exist unzip; then
set -A cmd istemp "unzip -avp" "$2" "$file2"
#endif
-#ifdef unrar
- elif [[ "$1" = *RAR\ archive* ]]; then
- if cmd_exist unrar; then
- set -A cmd istemp "unrar p -inul" "$2" "$file2"
- elif cmd_exist rar; then
- set -A cmd istemp "rar p -inul" "$2" "$file2"
- fi
-#elif rar
- elif [[ "$1" = *RAR\ archive* ]] && cmd_exist rar; then
- set -A cmd istemp "rar p -inul" "$2" "$file2"
-#endif
+#ifdef bsdtar
+ elif [[ "$1" = *RAR\ archive* ]] && cmd_exist bsdtar; then
+ set -A cmd bsdtar xOf "$2" "$file2"
+#endif
#ifdef 7za
elif [[ "$1" = *7-zip\ archive* || "$1" = *7z\ archive* ]] && cmd_exist 7za; then
set -A cmd istemp "7za e -so" "$2" "$file2"
@@ -705,19 +698,10 @@ isfinal() {
msg "use zip_file${sep}contained_file to view a file in the archive"
istemp "unzip -lv" "$2"
#endif
-#ifdef unrar
- elif [[ "$1" = *RAR\ archive* ]]; then
- if cmd_exist unrar; then
- msg "use rar_file${sep}contained_file to view a file in the archive"
- istemp "unrar v" "$2"
- elif cmd_exist rar; then
- msg "use rar_file${sep}contained_file to view a file in the archive"
- istemp "rar v" "$2"
- fi
-#elif rar
- elif [[ "$1" = *RAR\ archive* ]] && cmd_exist rar; then
+#ifdef bsdtar
+ elif [[ "$1" = *RAR\ archive* ]] && cmd_exist bsdtar; then
msg "use rar_file${sep}contained_file to view a file in the archive"
- istemp "rar v" "$2"
+ bsdtar tf "$2"
#endif
#ifdef 7za
elif [[ "$1" = *7-zip\ archive* || "$1" = *7z\ archive* ]] && cmd_exist 7za; then
|