Here's the workaround that I mentioned:
(defun db48x/shell-quote-arg-list (args)
(mapcar 'shell-quote-argument args))
(advice-add 'executable-interpret :filter-args 'db48x/shell-quote-arg-list '(name escape-command-name))
This tells emacs to run the db48x/shell-quote-arg-list
function on the argument list any time anyone calls executable-interpret
. This gives us a change to escape any spaces in it before it's passed off to the original function.
This works quite well; any spaces or shell metacharacters you give to executable-interpret
are escaped, and everything works quite well.
There is one downside, however. The next time you run executable-interpret
, it will reuse the same value again as the new default script to run. However, it saved the value after we escaped it, so if you use it as-is it will be escaped again. A more complex set of advice needs to be applied to get the right behavior, probably an :around function that escapes the argument, calls the original function, and then overwrites the variable holding the previous command with the unescaped version.
Edit:
Here's the better method I mentioned:
(defun db48x/executable-interpret-escaped (original-func command)
(funcall original-func (shell-quote-argument command))
(setf executable-command command))
(advice-add 'executable-interpret :around 'db48x/executable-interpret-escaped '(name escape-command-name))