/bin/sh bug

Vincent Stemen bsd at hightek.org
Sat Apr 17 11:21:34 PDT 2004


Another sh bug I think.
        
If you dot in a file from a script, $1 in the child script inherits
it's value from the parent and the arguments do not get passed.
This is on FreeBSD-5.1-RELEASE on the i386 platform.

The following examples compare the behavior to bash and zsh.  Zsh has
the most appropriate bahavior as it also properly sets $0.

$ cat test1

echo "$0: \$1 = [$1]"
. ./test2 test2arg

$ cat test2

echo "$0: \$1 = [$1]"

$ sh ./test1 foo
./test1: $1 = [foo]
./test1: $1 = [foo]

$ bash ./test1 foo
./test1: $1 = [foo]
./test1: $1 = [test2arg]

$ zsh ./test1 foo
./test1: $1 = [foo]
./test2: $1 = [test2arg]


-- 
Vincent Stemen
Avoid the VeriSign/Network Solutions domain registration trap!
http://www.InetAddresses.net



More information about the freebsd-bugs mailing list