Timeline for cURL in bash script reads $HOME as /root/
Current License: CC BY-SA 4.0
5 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Sep 24, 2024 at 12:01 | comment | added | Nickotine | impressive @terdon :D | |
| Sep 24, 2024 at 11:41 | comment | added | terdon♦ |
Yeah, you could get the home with userhome=$(awk -F: -v user="$SUDO_USER" '$1==user{print $6}' /etc/passwd) instead.
|
|
| Sep 24, 2024 at 11:10 | comment | added | Nickotine |
This seems to add unnecessary complexity, we are using eval adding an an extra variable and spawning a sub shell. The only way you can get the root directory is if you become root. @yuropoor could you check that please? do whoami if it comes up as root then do exit, thensudo bash script.bash that way you wouldn't need to change anything or add more code by just fixing your approach, if was a beginner looking at this I'd have no idea how it works, I'd just use it because it works (not good if you're new), going overkill like this bloats the code
|
|
| Sep 24, 2024 at 10:28 | vote | accept | Yuropoor | ||
| Sep 24, 2024 at 10:25 | history | answered | ReflectYourCharacter | CC BY-SA 4.0 |