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 From: "Hannu E K Nevalainen" <_garbage_collector_ AT telia DOT com> To: Subject: RE: read command available? Date: Wed, 18 Aug 2004 22:44:01 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit In-Reply-To: X-IsSubscribed: yes Igor wrote: > On Wed, 18 Aug 2004, Hannu E K Nevalainen wrote: >> As I'm not familiar with ksh, so: >> -- *bash* usage example -- >> #!/bin/bash >> >> cd / >> ls | ( >> while read TEST ;do >> echo -n $TEST >> done >> ) > > Two points to note: > > 1) there's no need for the parentheses in the above expression -- > in fact, > they actually change the semantics, as the "while" will be invoked in > a subshell. Sorry, bash semantics isn't changed (ksh might be another case, as it's man page states). bash uses a subshell for the 'while' no matter what you do - this is obviously considered some kind of optimization, -stupidity IMO (one has to go to extremes to catch what has been read). I found this out - the hard way. Typing the parantheses makes it clear what actually happens; that's why they're there in the above snippet. Add a last line of echo "After loop: $TEST" above and you'll see the TEST variable beeing unset; i.e. it was used in a subshell (otherwise it would hold the last file or dir name). > 2) the exact same command (with or without the parentheses) works in > ksh, so I was unable to reproduce the OP's problem. So does it for me. I never tried it straight OOTB, bugger. /Hannu E K Nevalainen, B.Sc. EE Microcomputer systems --72--> ** mailing list preference; please keep replies on list ** -- printf("LocalTime: UTC+%02d\n",(DST)? 2:1); -- --END OF MESSAGE-- -- 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/