From d23c1eec3d72183cfeb41e8e5c5bd6c15349ceed Mon Sep 17 00:00:00 2001
From: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Date: Thu, 8 Oct 2020 23:59:32 +0200
Subject: [PATCH 2/5] add plenty of missing 'which' commands in ext.d
the construct 'if <command>' to check the presence of a command would
work in some cases (though inefficiently), but it others it was just
bogus. in every case it was inconsistent and confusing.
---
misc/ext.d/doc.sh.in | 16 ++++++++--------
misc/ext.d/image.sh | 2 +-
misc/ext.d/misc.sh.in | 2 +-
misc/ext.d/video.sh | 6 +++---
4 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/misc/ext.d/doc.sh.in b/misc/ext.d/doc.sh.in
index 871773c3a..72deae7dd 100644
a
|
b
|
staroffice_console() { |
25 | 25 | } |
26 | 26 | |
27 | 27 | get_ooffice_executable() { |
28 | | if loffice >/dev/null 2>&1; then |
| 28 | if which loffice >/dev/null 2>&1; then |
29 | 29 | echo "loffice" |
30 | | elif ooffice >/dev/null 2>&1; then |
| 30 | elif which ooffice >/dev/null 2>&1; then |
31 | 31 | echo "ooffice" |
32 | 32 | else |
33 | 33 | echo -n |
… |
… |
do_view_action() { |
52 | 52 | fi |
53 | 53 | ;; |
54 | 54 | msdoc) |
55 | | if wvHtml >/dev/null 2>&1; then |
| 55 | if which wvHtml >/dev/null 2>&1; then |
56 | 56 | tmp=`mktemp -d ${TMPDIR:-/tmp}/%p.XXXXXX` |
57 | 57 | wvHtml "${MC_EXT_FILENAME}" --targetdir="$tmp" page.html |
58 | 58 | elinks -dump "$tmp/page.html" |
59 | 59 | rm -rf "$tmp" |
60 | | elif antiword >/dev/null 2>&1; then |
| 60 | elif which antiword >/dev/null 2>&1; then |
61 | 61 | antiword -t "${MC_EXT_FILENAME}" |
62 | | elif catdoc >/dev/null 2>&1; then |
| 62 | elif which catdoc >/dev/null 2>&1; then |
63 | 63 | catdoc -w "${MC_EXT_FILENAME}" |
64 | | elif word2x >/dev/null 2>&1; then |
| 64 | elif which word2x >/dev/null 2>&1; then |
65 | 65 | word2x -f text "${MC_EXT_FILENAME}" - |
66 | 66 | else |
67 | 67 | strings "${MC_EXT_FILENAME}" |
68 | 68 | fi |
69 | 69 | ;; |
70 | 70 | msxls) |
71 | | if xlhtml >/dev/null 2>&1; then |
| 71 | if which xlhtml >/dev/null 2>&1; then |
72 | 72 | tmp=`mktemp -d ${TMPDIR:-/tmp}/%p.XXXXXX` |
73 | 73 | xlhtml -a "${MC_EXT_FILENAME}" > "$tmp/page.html" |
74 | 74 | elinks -dump "$tmp/page.html" |
75 | 75 | rm -rf "$tmp" |
76 | | elif xls2csv >/dev/null 2>&1; then |
| 76 | elif which xls2csv >/dev/null 2>&1; then |
77 | 77 | xls2csv "${MC_EXT_FILENAME}" |
78 | 78 | else |
79 | 79 | strings "${MC_EXT_FILENAME}" |
diff --git a/misc/ext.d/image.sh b/misc/ext.d/image.sh
index 583c09ecf..04307e01b 100755
a
|
b
|
do_open_action() { |
45 | 45 | else |
46 | 46 | (gqview "${MC_EXT_FILENAME}" &) |
47 | 47 | fi |
48 | | elif see >/dev/null 2>&1; then |
| 48 | elif which see >/dev/null 2>&1; then |
49 | 49 | (see "${MC_EXT_FILENAME}" &) |
50 | 50 | else |
51 | 51 | (zgv "${MC_EXT_FILENAME}" &) |
diff --git a/misc/ext.d/misc.sh.in b/misc/ext.d/misc.sh.in
index f4b0bd47b..32a5f3f8d 100644
a
|
b
|
do_open_action() { |
71 | 71 | sqlite3 "${MC_EXT_FILENAME}" |
72 | 72 | ;; |
73 | 73 | glade) |
74 | | if glade-3 --version >/dev/null 2>&1; then |
| 74 | if which glade-3 >/dev/null 2>&1; then |
75 | 75 | (glade-3 "${MC_EXT_FILENAME}" >/dev/null 2>&1 &) |
76 | 76 | else |
77 | 77 | (glade-2 "${MC_EXT_FILENAME}" >/dev/null 2>&1 &) |
diff --git a/misc/ext.d/video.sh b/misc/ext.d/video.sh
index 979a50acc..9cba21020 100755
a
|
b
|
do_view_action() { |
13 | 13 | |
14 | 14 | case "${filetype}" in |
15 | 15 | *) |
16 | | if mplayer >/dev/null 2>&1; then |
| 16 | if which mplayer >/dev/null 2>&1; then |
17 | 17 | mplayer -identify -vo null -ao null -frames 0 "${MC_EXT_FILENAME}" 2>&1 | \ |
18 | 18 | sed -n 's/^ID_//p' |
19 | 19 | elif which mpv_identify.sh >/dev/null 2>&1; then |
… |
… |
do_view_action() { |
28 | 28 | do_open_action() { |
29 | 29 | filetype=$1 |
30 | 30 | |
31 | | if mpv >/dev/null 2>&1; then |
| 31 | if which mpv >/dev/null 2>&1; then |
32 | 32 | PLAYER=mpv |
33 | | elif mplayer >/dev/null 2>&1; then |
| 33 | elif which mplayer >/dev/null 2>&1; then |
34 | 34 | PLAYER=mplayer |
35 | 35 | else |
36 | 36 | echo "Please install either mplayer or mpv to play this file" |