From 31e7a7e9638b2d403af484526ad3f28cbc2cf37d Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 8 Oct 2020 23:59:32 +0200 Subject: [PATCH] Ticket #4127: several improvements to mc.ext and syntax highlighting. add plenty of missing 'which' commands in ext.d. the construct 'if ' 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. Signed-off-by: Andrew Borodin --- 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/misc/ext.d/doc.sh.in +++ b/misc/ext.d/doc.sh.in @@ -25,9 +25,9 @@ staroffice_console() { } get_ooffice_executable() { - if loffice >/dev/null 2>&1; then + if which loffice >/dev/null 2>&1; then echo "loffice" - elif ooffice >/dev/null 2>&1; then + elif which ooffice >/dev/null 2>&1; then echo "ooffice" else echo -n @@ -52,28 +52,28 @@ do_view_action() { fi ;; msdoc) - if wvHtml >/dev/null 2>&1; then + if which wvHtml >/dev/null 2>&1; then tmp=`mktemp -d ${TMPDIR:-/tmp}/%p.XXXXXX` wvHtml "${MC_EXT_FILENAME}" --targetdir="$tmp" page.html elinks -dump "$tmp/page.html" rm -rf "$tmp" - elif antiword >/dev/null 2>&1; then + elif which antiword >/dev/null 2>&1; then antiword -t "${MC_EXT_FILENAME}" - elif catdoc >/dev/null 2>&1; then + elif which catdoc >/dev/null 2>&1; then catdoc -w "${MC_EXT_FILENAME}" - elif word2x >/dev/null 2>&1; then + elif which word2x >/dev/null 2>&1; then word2x -f text "${MC_EXT_FILENAME}" - else strings "${MC_EXT_FILENAME}" fi ;; msxls) - if xlhtml >/dev/null 2>&1; then + if which xlhtml >/dev/null 2>&1; then tmp=`mktemp -d ${TMPDIR:-/tmp}/%p.XXXXXX` xlhtml -a "${MC_EXT_FILENAME}" > "$tmp/page.html" elinks -dump "$tmp/page.html" rm -rf "$tmp" - elif xls2csv >/dev/null 2>&1; then + elif which xls2csv >/dev/null 2>&1; then xls2csv "${MC_EXT_FILENAME}" else strings "${MC_EXT_FILENAME}" diff --git a/misc/ext.d/image.sh b/misc/ext.d/image.sh index 583c09ecf..04307e01b 100755 --- a/misc/ext.d/image.sh +++ b/misc/ext.d/image.sh @@ -45,7 +45,7 @@ do_open_action() { else (gqview "${MC_EXT_FILENAME}" &) fi - elif see >/dev/null 2>&1; then + elif which see >/dev/null 2>&1; then (see "${MC_EXT_FILENAME}" &) else (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/misc/ext.d/misc.sh.in +++ b/misc/ext.d/misc.sh.in @@ -71,7 +71,7 @@ do_open_action() { sqlite3 "${MC_EXT_FILENAME}" ;; glade) - if glade-3 --version >/dev/null 2>&1; then + if which glade-3 >/dev/null 2>&1; then (glade-3 "${MC_EXT_FILENAME}" >/dev/null 2>&1 &) else (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/misc/ext.d/video.sh +++ b/misc/ext.d/video.sh @@ -13,7 +13,7 @@ do_view_action() { case "${filetype}" in *) - if mplayer >/dev/null 2>&1; then + if which mplayer >/dev/null 2>&1; then mplayer -identify -vo null -ao null -frames 0 "${MC_EXT_FILENAME}" 2>&1 | \ sed -n 's/^ID_//p' elif which mpv_identify.sh >/dev/null 2>&1; then @@ -28,9 +28,9 @@ do_view_action() { do_open_action() { filetype=$1 - if mpv >/dev/null 2>&1; then + if which mpv >/dev/null 2>&1; then PLAYER=mpv - elif mplayer >/dev/null 2>&1; then + elif which mplayer >/dev/null 2>&1; then PLAYER=mplayer else echo "Please install either mplayer or mpv to play this file"