all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Benjamin Ragheb" <ben@benzado.com>
To: 33984@debbugs.gnu.org
Subject: bug#33984: 26.1; fortune-compile does not search exec-path for strfile program
Date: Fri, 04 Jan 2019 21:54:28 -0500	[thread overview]
Message-ID: <dac8fdc9-13e6-49be-b1ca-c00dee8518ef@www.fastmail.com> (raw)

[-- 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)))))
 

             reply	other threads:[~2019-01-05  2:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-05  2:54 Benjamin Ragheb [this message]
2019-07-09 22:32 ` bug#33984: 26.1; fortune-compile does not search exec-path for strfile program Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dac8fdc9-13e6-49be-b1ca-c00dee8518ef@www.fastmail.com \
    --to=ben@benzado.com \
    --cc=33984@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.