home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!rphroy!ilium!sycom!curlie!thierry
- From: thierry@curlie.UUCP (Thierry Lach )
- Newsgroups: comp.unix.questions
- Subject: Re: csh foreach question
- Keywords: csh,foreach
- Message-ID: <wX3gPB3w164w@curlie.UUCP>
- Date: 14 Aug 92 01:21:07 GMT
- References: <BswB6M.Dxw@news.cso.uiuc.edu>
- Organization: Not An Organization
- Lines: 39
-
- gordon@osiris.cso.uiuc.edu (John Gordon) writes:
-
- >
- > Given the following script:
- > #
- > foreach line ( `cat this_script` )
- > echo "$line"
- > end
- >
- >
- > I would expect the output to be:
- >
- > #
- > foreach line ( `cat this_script` )
- > echo "$line"
- > end
- >
- > However, I get:
- >
- > #
- > foreach
- > line
- > (
- > )
- > echo
- > "$line"
- > end
- >
- > Is this what's supposed to happen? Any help appreciated.
- >
- > ---
- > John Gordon My incredibly witty saying has been
- > gordon@osiris.cso.uiuc.edu Politically Corrected into oblivion.
-
- Yes. The `cat this_script` will take each token (as recognized
- by the shell, meaning anything delimited by whitespace), and
- make it an argument to the foreach. Because newline is whitespace,
- they are not maintained, and because the echo does not override
- the newline, you get one token per line.
-