Sample Header Ad - 728x90

Command output evaluation not working in Bash script

1 vote
1 answer
1150 views
I am trying to automate adding Homebrew to my path in a shell script, but these two lines do not evaluate inside my shell script:
#!/bin/sh
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
The second line of code runs the program [home]brew with [the argument shellenv](https://github.com/Homebrew/brew/blob/master/Library/Homebrew/cmd/shellenv.sh) . It echoes several environment variables to set which are then evaluated. The first line just adds the second line to my ~/.profile so brew's PATH is setup in every shell. I noticed that this statement does not work in my shell script, ***but*** it does when I type it into my terminal. What might be causing this? I tried running the commands I was instructed to run after Homebrew installed in a shell script and got the same behavior. **similar question:** - [problem with homebrew installation path on linux](https://unix.stackexchange.com/questions/713835/problem-with-homebrew-installation-path-on-linux)
Asked by unrealapex (132 rep)
Feb 16, 2023, 01:37 AM
Last activity: Feb 19, 2023, 08:41 AM