all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#33984: 26.1; fortune-compile does not search exec-path for strfile program
@ 2019-01-05  2:54 Benjamin Ragheb
  2019-07-09 22:32 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 2+ messages in thread
From: Benjamin Ragheb @ 2019-01-05  2:54 UTC (permalink / raw)
  To: 33984

[-- Attachment #1: Type: text/plain, Size: 1114 bytes --]

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.

[-- Attachment #2: fortune.el.patch --]
[-- Type: application/octet-stream, Size: 1017 bytes --]

--- fortune.el.master	2019-01-04 20:37:38.000000000 -0500
+++ fortune.el.strfile-fix	2019-01-04 21:12:09.000000000 -0500
@@ -244,12 +244,14 @@
   (let* ((fortune-file (expand-file-name (substitute-in-file-name file)))
 	 (fortune-dat (expand-file-name
 		       (substitute-in-file-name
-			(concat fortune-file fortune-database-extension)))))
+			(concat fortune-file fortune-database-extension))))
+         (strfile (or (executable-find fortune-strfile)
+                      (error "Can't find strfile program %s" fortune-strfile)))
   (cond ((file-exists-p fortune-file)
          (cond ((file-newer-than-file-p fortune-file fortune-dat)
                 (message "Compiling new fortune database %s" fortune-dat)
                 (shell-command
-                 (concat fortune-strfile fortune-strfile-options
+                 (concat strfile fortune-strfile-options
                          " " fortune-file fortune-quiet-strfile-options)))))
 	(t (error "Can't compile fortune file %s" fortune-file)))))
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-07-09 22:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-05  2:54 bug#33984: 26.1; fortune-compile does not search exec-path for strfile program Benjamin Ragheb
2019-07-09 22:32 ` Lars Ingebrigtsen

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.