Skip to main content
9 events
when toggle format what by license comment
May 10, 2019 at 12:55 comment added Jiri Fornous There could also be problems with script arguments - some scripts rely heavily on $0 param - which should be the script name, but here it is the shell it self. It can produce some unexpected behavior (dirname $0)...
Apr 1, 2016 at 18:28 comment added Wildcard @71GA, the factual answer to this is: You can't use sudo to run a shell built-in (and it wouldn't make any sense if you could).
Sep 27, 2014 at 13:52 comment added enzotib @71GA: depending on compilation preferences for sudo and depending on configuration settings in /etc/sudoers you can or cannot preserve your environment when running commands with sudo. I suggest you to try to source your script, and then run sudo with -E option to preserve the environment. If it does not work, I suppose there is very little you can do.
Sep 27, 2014 at 13:37 comment added 71GA While source ./script works completely fine, sudo source ./script.sh says sudo: source: command not found. How can I do this using sudo?
Feb 21, 2012 at 13:24 comment added enzotib @Patryk: maybe your script has an exit statement, so it is not suitable to be sourced.
Feb 21, 2012 at 13:03 comment added Patryk @glennjackman I have a similar problem and I have tried your solution but it logs me off from shell when I do . or source. Why is this happening ?
Jan 27, 2012 at 20:32 comment added glenn jackman the reason is that your script spawns a new shell process as a child of the current shell. Any environment changes you make in the child process cannot affect the parent. When you use . or source, you are not spawning a new child process, you are running the commands in the current shell.
Jan 27, 2012 at 20:28 vote accept cwd
Jan 27, 2012 at 20:12 history answered enzotib CC BY-SA 3.0