id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	blockedby	blocking	branch_state	votes
3926	mc shows error message for each not-installed program libexec/mc/ext.d/doc.sh tries to access	marcelpaulo	andrew_b	"{{{
paulo:~/src/mc (master)$ mc -V
GNU Midnight Commander 4.8.21-8-g6cdd3b7ad
Built with GLib 2.56.1
Using the S-Lang library with terminfo database
With builtin Editor
With subshell support as default
With support for background operations
With mouse support on xterm
With support for X11 events
With internationalization support
With multiple codepages support
Virtual File Systems: cpiofs, tarfs, sfs, extfs, ftpfs, sftpfs, fish
Data types: char: 8; int: 32; long: 64; void *: 64; size_t: 64; off_t: 64;
}}}

When viewing //*.doc// files, for instance:
[[Image(https://i.imgur.com/K1WXYkn.png)]]

the file is rendered with the first viewer that can be found, but an error message is shown for every viewer which is tried and not found:
[[Image(https://i.imgur.com/eJsUu5F.png)]]

Here's the section from my //~/.config/mc/mc.ext// that handles //*.doc// files (I haven't changed it from the default settings):

{{{
# Microsoft Word Document
regex/i/\.(do[ct]|wri)$
	Open=/usr/local/libexec/mc/ext.d/doc.sh open msdoc
	View=%view{ascii} /usr/local/libexec/mc/ext.d/doc.sh view msdoc

type/^Microsoft\ Word
	Open=/usr/local/libexec/mc/ext.d/doc.sh open msdoc
	View=%view{ascii} /usr/local/libexec/mc/ext.d/doc.sh view msdoc
}}}

and here's the code from ///usr/local/libexec/mc/ext.d/doc.sh// that handles `msdoc`:

{{{
    msdoc)
        which wvHtml >/dev/null 2>&1 &&
        {
            tmp=`mktemp -d ${TMPDIR:-/tmp}/%p.XXXXXX`
            wvHtml ""${MC_EXT_FILENAME}"" --targetdir=""$tmp"" page.html
            elinks -dump ""$tmp/page.html""
            rm -rf ""$tmp""
        } || \
            antiword -t ""${MC_EXT_FILENAME}"" || \
            catdoc -w ""${MC_EXT_FILENAME}"" || \
            word2x -f text ""${MC_EXT_FILENAME}"" - || \
            strings ""${MC_EXT_FILENAME}""
        ;;
}}}

I don't have neither `wv` nor `antiword` installed:

{{{
paulo:~/tmp$ apt policy wv
wv:
  Installed: (none)
  Candidate: 1.2.9-4.2build1
  Version table:
     1.2.9-4.2build1 500
        500 http://archive.ubuntu.com/ubuntu bionic/universe amd64 Packages
paulo:~/tmp$ apt policy antiword
antiword:
  Installed: (none)
  Candidate: 0.37-11build1
  Version table:
     0.37-11build1 500
        500 http://archive.ubuntu.com/ubuntu bionic/universe amd64 Packages
}}}

so, `antiword` is run but not found, hence the error message I got. As `catdoc` is installed:

{{{
paulo:~/tmp$ apt policy catdoc
catdoc:
  Installed: 1:0.95-4.1
  Candidate: 1:0.95-4.1
  Version table:
 *** 1:0.95-4.1 500
        500 http://archive.ubuntu.com/ubuntu bionic/universe amd64 Packages
        100 /var/lib/dpkg/status
}}}

it's run and it renders the file.

The presence of the alternatives `antiword`, `catdoc`, `word2x` and `strings` should be tested with `which`, just like `wv` was tested, to prevent an error message to be shown for each one which's not found."	defect	closed	minor	4.8.22	mc-core	master	fixed	mc.ext msdoc doc.sh				merged	committed-master
