strange shell behavior...thoughts?

Kevin Martin kevintm at ameritech.net
Mon Sep 15 04:50:20 UTC 2008


So I'm fairly confused at this point.

Start with a /bin/sh shell.

Then do:

sh-3.2$ unset $?
sh: unset: `0': not a valid identifier

ok, no problem; then do

sh-3.2$ /bin/ksh -c " set -xv  ; grep ABCD  b ; echo $? ; if [ "$?" =
"0" ] ; then echo yes ; fi"
+ grep ABCD b
ABCD="C" ; export ABCD
+ echo 1
1
+ [ 1 = 0 ]

WHAT? 

Then do it again without unsetting $?:
sh-3.2$ /bin/ksh -c " set -xv  ; grep ABCD b ; echo $? ; if [ "$?" = "0"
] ; then echo yes ; fi"
+ grep ABCD b
ABCD="C" ; export ABCD
+ echo 0
0
+ [ 0 = 0 ]
+ echo yes
yes


Why doesn't the first iteration work?  Is this a ksh bug?

Thanks.

Kevin





More information about the fedora-list mailing list