This is the mail archive of the
mailing list for the Cygwin project.
Re: Bash scripting broken under Cygwin?
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:
> Replies inline below.
> On Fri, 9 May 2003 email@example.com 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 22.214.171.124
> 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 <http://cygwin.com/problems.html>. 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.
> |\ _,,,---,,_ firstname.lastname@example.org
> ZZZzz /,`.-'`' -. ;-;;,_ email@example.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