2009/7/19 Romain Tartière <rom...@blogreen.org>:
> Hi!
>
> Simple test case:
>
> ----8<----------------------
> #!/bin/sh
> foo()
> {
>  echo "\$?=$? \$1=$1"
> }
> false
> foo $?
> ----8<----------------------
>
> % sh foo.sh
> $?=0 $1=1
> % zsh foo.sh
> $?=1 $1=1
> % bash foo.sh
> $?=1 $1=1
>
> As you can see, the value of $? is « lost » when FreeBSD sh enters a
> function.  Is this supposed to behave this way?
>

Hi.

I'm no expert at shell scripting, but my first presumption is that
since you have '#!/bin/sh' at the beginning of the script, it is
creating a new subshell, and overwriting the value.  What happens if
you replace '#!/bin/sh' with '#!/usr/local/bin/zsh' ?

-- 
Glen Barber
_______________________________________________
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to "freebsd-stable-unsubscr...@freebsd.org"

Reply via email to