purcell / exec-path-from-shell

Make Emacs use the $PATH set up by the user's shell
Other
1.43k stars 82 forks source link

Fail gracefully if SHELL is not defined. #51

Closed jasonm23 closed 7 years ago

jasonm23 commented 7 years ago

Seems that some environments don't pass SHELL.

This causes the predicate which checks for standard shell to fail with a stringp / nil type error.

jasonm23 commented 7 years ago

exec-path-from-shell--standard-shell-p the predicate in question.

jasonm23 commented 7 years ago

I think it should throw an error like this:

(defun exec-path-from-shell--standard-shell-p (shell)
  "Return non-nil iff SHELL supports the standard ${VAR-default} syntax."
  (if (not (eq shell nil))
      (not (string-match "\\(fish\\|t?csh\\)$" shell))
    (error "SHELL is not defined")))

Or maybe just a warning:

(defun exec-path-from-shell--standard-shell-p (shell)
  "Return non-nil iff SHELL supports the standard ${VAR-default} syntax."
  (if (not (eq shell nil))
      (not (string-match "\\(fish\\|t?csh\\)$" shell))
    (message "Warning: SHELL is not defined")))
jasonm23 commented 7 years ago

(of course the message option will need to return a nil too)

jasonm23 commented 7 years ago

@purcell if you would prefer one way or the other, let me know. I'm happy to code it if you don't have time.

purcell commented 7 years ago

Thanks. Addressed in 0f53502.

jasonm23 commented 7 years ago

Thanks