Closed jaredbrogan closed 2 years ago
Problem is, the script usually is run as root sudo ./update-golang.sh
. Sourcing the profile in the sudo
context will not affect the user shell when sudo exits.
Maybe, another approach is to leave a message to user that one might need to source the profile in order to get immediate effect?
Very good point! I do think your suggestion of outputting a message to the user to source it upon completion. You might want to consider putting it at the end of the script output, separating the message with a newline at the start, otherwise users may not see it as easily.
I have added this https://github.com/udhos/update-golang/commit/20a10826721e76d6db24d05282b65fac2e94661f:
update-golang.sh:
update-golang.sh: HINT: If this is the first time you run this script, the env vars
update-golang.sh: updated in the profile will only take effect for new shells.
update-golang.sh: If you want them to affect the current shell, use this:
update-golang.sh:
update-golang.sh: source /etc/profile.d/golang_path.sh
update-golang.sh:
Does it help?
Yep, looks good!
After executing
sudo ./update-golang.sh
(when performing a clean install), I expect to immediately be able to run go commands from anywhere. However, since the profile modifications aren't sourced after being created or updated, the user will have to either do it themselves manually or re-login to their session to access it globally.Suggested changes: Add
source "$abs_profiled"
after line #320