[sudo-users] sudo, ksh, $0 - interesting behavior

Kevin Shortt kevinshortt at gmail.com
Thu Aug 4 11:46:01 EDT 2011


Hi everyone,

I have an interesting issue.  $0 in a ksh script is scrubbed and sets
differently when using sudo and symlinks for the executed script.
Here is a copy of the test script, and an example of the behavior.

I am still investigating, but thought I would ask the group if they have
experienced this before.


===BEGIN:  test.sh
#!/bin/ksh

echo "$ 0:[$0]";
===END:  test.sh


serverA:$ pwd
/home/kevinshortt
serverA:$ ls -ld test.sh
-rwx------  1 kevinshortt  staff  29 Aug  4 11:40 test.sh ->
/usr/local/bin/test.sh

serverA:$ ./test.sh
$ 0:[./test.sh]

serverA:$ sudo ./test.sh
$ 0:[/usr/local/bin/test.sh]



More information about the sudo-users mailing list