Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , 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: Fri, 9 May 2003 18:36:25 -0400 (EDT) From: lists AT m8y DOT org X-X-Sender: nemo AT nautilus DOT m8y DOT org To: cygwin AT cygwin DOT com Subject: Re: Bash scripting broken under Cygwin? In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Regarding extensive response below, see the link I posted in reply to myself, I think it deals with the problem. Script responses verified by hand, by running grep -A2 '$Log' /path/to/file | grep -q derek on one of the echoed files, and not getting exit status of 0 On Fri, 9 May 2003, Igor Pechtchanski wrote: > Derek, > > Replies inline below. > > On Fri, 9 May 2003 lists AT m8y DOT org wrote: > > > $ cat temp.txt | while read f;do grep -A2 '$Log' $f | grep -q derek;if [ $? -eq "0" ];then echo $f;fi;done > > > > This oneliner, for example, reads a list of files, does a grep for > > something I'm interested in, and echos the file if found. > > I'm assuming this illustrates a problem with some other script of yours, > and that you aren't interested in alternate ways of doing the above. > Please correct me if I'm wrong. > > > Under Cygwin, I have verified invalid responses. > > Invalid responses being?.. The following trivial modification of the > above works for me: > > cat temp.txt | while read f;do grep -B4 'shutdown' $f | grep -q install;if [ $? -eq "0" ];then echo $f;fi;done > > > It seems to be because $? is the exit status of the last command, but > > according to the process list, Cygwin seems to run the greps in > > background, at once. I've never been able to get this to happen on > > other unixes I've tried similar loops on. > > When you create a pipe chain in bash, all the commands in the chain do run > simultaneously, each in its own subshell, reading from the input pipe and > writing to the output one. > > The exit status of each command in a pipe can be accessed (in bash) > through the PIPESTATUS array variable. The exit status of a pipe should > be the status of the last command (so the above script should work). > > > Is this supposed to be a performance inhancement? It really messes up > > simple scripts. > > I'm not sure what you mean -- *all* the commands in a pipe are supposed to > run in parallel... at least on Unix. They didn't use to in DOS - the > output of the first command was written to a temporary file, and it was > then read by the second command. > > > Cygwin was installed on this computer back at: > > 2002/11/06 11:50:52 Starting cygwin install, version 2.249.2.5 > > FYI, the above is the version of "setup.exe" that you used to install > Cygwin, not the version of Cygwin itself. > > > Can include the full log if people want more version numbers. > > Thanks, > > Derek > > The regular way to do this is to run "cygcheck -svr" and attach the output > (see . This will include your full > environment, your mount points, your ntsec settings, etc. If you want to > list the package version numbers only, use "cygcheck -c" instead. > Igor > -- > http://cs.nyu.edu/~pechtcha/ > |\ _,,,---,,_ pechtcha AT cs DOT nyu DOT edu > ZZZzz /,`.-'`' -. ;-;;,_ igor AT watson DOT ibm DOT com > |,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski > '---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow! > > Knowledge is an unending adventure at the edge of uncertainty. > -- Leto II > > -- 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/