Skip to content

Make parsing more reliable#1

Merged
purcell merged 1 commit into
purcell:masterfrom
swsnr:extract-via-marker
Sep 13, 2012
Merged

Make parsing more reliable#1
purcell merged 1 commit into
purcell:masterfrom
swsnr:extract-via-marker

Conversation

@swsnr

@swsnr swsnr commented Sep 13, 2012

Copy link
Copy Markdown
Contributor

exec-path-from-getenv isn't reliable, because it assumes that the $PATH is the only output of the subprocess. A shell however may emit more output from the user's shell configuration files, i.e. a welcome message from fortune or something the like of. In such cases, exec-path and $PATH are spoiled and become useless, because arbitrary strings end up there.

This patch is my attempt to fix this short-coming. I insert a marker string (__RESULT=) into the echo command, and search the output of the subprocess for this marker.

I've also replaced shell-command-to-string with a direct call to call-process because it's somewhat absurd to use a shell to spawn the shell ;)

An interactive shell may have additional output depending on the user's shell
configuration.  Insert a marker and extract the value via this marker to make
sure that only the actual "$PATH" content is returned.
@purcell purcell merged commit 4223b12 into purcell:master Sep 13, 2012
@purcell

purcell commented Sep 13, 2012

Copy link
Copy Markdown
Owner

Thanks. The ideal, of course, would be to make the sub-shell non-interactive, but people would be confused when settings in their .bashrc were ignored... sigh.

@swsnr

swsnr commented Sep 13, 2012

Copy link
Copy Markdown
Contributor Author

Initially I thought about removing -i, too, but then it occurred to that I've a lot of useful $PATH additions in my .zshrc, too. Thanks for merging.

@purcell

purcell commented Sep 13, 2012

Copy link
Copy Markdown
Owner

That might be why I originally had the -i there: I'm also a zsh guy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants