Subject: bug#33984: 26.1; fortune-compile does not search exec-path for strfile program

From: "Benjamin Ragheb" <[email-masked]>
Date: Fri, 04 Jan 2019 21:54:28 -0500

I am using Emacs 26.1 on macOS 10.14.2 Mojave. macOS does not include the fortune or strfile programs, so I install them using MacPorts, which places them in /opt/local/bin. By default, that directory is not on the PATH, so I have the following line in init.el:

    (add-to-list 'exec-path "/opt/local/bin")

With this setup, running M-x fortune works as expected (because the fortune command uses call-process to invoke the fortune program).

However, M-x fortune-compile fails with this error:

    /bin/bash: strfile: command not found

I have determined this is because fortune-compile passes the value of the fortune-strfile variable directly to shell-command, which does not consult exec-path.

I have attached a patch which corrects this problem by using executable-find before calling shell-command. If strfile cannot be found, it signals an error.

I tried to keep the patch as small as possible, and resisted the temptation to replace the call to shell-command with call-process. Doing so would have broken compatibility with the fortune-quiet-strfile-options variable, which people may have customized.