delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/01/19/18:28:43

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Wed, 19 Jan 2005 18:27:39 -0500 (EST)
From: Igor Pechtchanski <pechtcha AT cs DOT nyu DOT edu>
Reply-To: cygwin AT cygwin DOT com
To: David Kramer <david AT thekramers DOT net>
cc: cygwin AT cygwin DOT com
Subject: Re: pdksh not setting $? with exit status of commands
In-Reply-To: <loom.20050119T220318-4@post.gmane.org>
Message-ID: <Pine.GSO.4.61.0501191821490.21835@slinky.cs.nyu.edu>
References: <loom DOT 20050119T161314-452 AT post DOT gmane DOT org> <Pine DOT GSO DOT 4 DOT 61 DOT 0501191509070 DOT 20608 AT slinky DOT cs DOT nyu DOT edu> <loom DOT 20050119T220318-4 AT post DOT gmane DOT org>
MIME-Version: 1.0

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 AT cs DOT nyu DOT edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor AT watson DOT ibm DOT 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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019