homebrew.sh icon indicating copy to clipboard operation
homebrew.sh copied to clipboard

Quoting on echo to Shell Init Files

Open craigsadler opened this issue 2 years ago • 1 comments

It appears the quoting might be a different to allow the HOMEBREW_PREFIX variable to properly resolve to its contents in the tee command:

echo 'export PATH="${HOMEBREW_PREFIX}/opt/openssl/bin:$PATH"'

results in shell files getting:

export PATH="${HOMEBREW_PREFIX}/opt/openssl/bin:$PATH"

While,

echo 'export PATH='"${HOMEBREW_PREFIX}/opt/openssl/bin:$PATH"

Does what is intended, i.e. shell files get a good PATH assignment.

export PATH=/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin

craigsadler avatar May 19 '22 23:05 craigsadler

Actually, that won't quite do it. We need the '$PATH' to be expanded as late as possible so it needs to be in the rc files as $PATH.

I will do some experimentation over the weekend. but I suspect

echo 'export PATH="'"${HOMEBREW_PREFIX}"'/opt/openssl/bin:$PATH"'

might do the trick, at the same time allowing for a space in either HOMEBREW_PREFIX or PATH

Honestpuck avatar May 20 '22 10:05 Honestpuck