This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: pdksh not setting $? with exit status of commands
On Wed, 19 Jan 2005, David Kramer wrote:
> Igor Pechtchanski <pechtcha <at> cs.nyu.edu> writes:
> > On Wed, 19 Jan 2005, David Kramer wrote:
> >
> > > When I execute commands in the pdksh shell that should set an exit
> > > value, $? is not being set. When I use the bash shell, it is.
> > >
> > > In pdksh:
> > > /c/windevel> grep o regexps
> > > oo
> > > /c/windevel> echo $?
> > > 0
> > > /c/windevel> grep Z regexps
> > > /c/windevel> echo $?
> > > 0
> >
> > Can't reproduce this here, sorry:
> >
> > $ pdksh
> > $ cygcheck -f /bin/pdksh
> > pdksh-5.2.14-3
> > $ grep o regexps ; echo $?
> > oo
> > 0
> > $ grep Z regexps ; echo $?
> > 1
>
> I see a functional difference in your example and mine. You ran grep
> then echo separated by a ;, while I ran it on two separate lines.
Hmm, interesting. I tried both ways, and they both worked identically for
me, so I posted the one that used less space...
> These should do the same thing (as it does on my other target, AIX), but
> it doesn't appear to.
>
> When I run your example in my Cygwin pdksh shell, I get the same results
> as you. It looks like I can use that format as a workaround for the
> problem, but I sure would like to understand why it doesn't work as
> expected in my example, when both examples produce the same results in
> AIX's ksh, so I can predict these kinds of problems in the future
> better.
>
> Cygwin Configuration Diagnostics
> Current System Time: Wed Jan 19 16:13:42 2005
>
> Windows XP Professional Ver 5.1 Build 2600 Service Pack 1
> [snip]
> Found: C:\cygwin\bin\grep.exe
> Found: c:\SFU\common\grep.exe
> Warning: C:\cygwin\bin\grep.exe hides c:\SFU\common\grep.exe
Ah, I think this may be your problem. Are you *sure* you're using the
Cygwin grep? In general, mixing MS SFU and Cygwin in the PATH is not a
good idea.
Try explicitly using /bin/grep, i.e.,
$ /bin/grep o regexps
oo
$ echo $?
0
$ /bin/grep Z regexps
$ echo $?
1
Igor Pechtchanski, Cygwin volunteer PDksh maintainer
--
http://cs.nyu.edu/~pechtcha/
|\ _,,,---,,_ pechtcha@cs.nyu.edu
ZZZzz /,`.-'`' -. ;-;;,_ igor@watson.ibm.com
|,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski, Ph.D.
'---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow!
"The Sun will pass between the Earth and the Moon tonight for a total
Lunar eclipse..." -- WCBS Radio Newsbrief, Oct 27 2004, 12:01 pm EDT
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/