[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bash - confusing the user - a headsup/FYI/whatever
From: |
Chet Ramey |
Subject: |
Re: bash - confusing the user - a headsup/FYI/whatever |
Date: |
Sat, 31 Dec 2005 16:34:53 -0500 |
User-agent: |
Thunderbird 1.5 (Macintosh/20051201) |
Hannu E K Nevalainen wrote:
> Problem:
> If I understand the "$ help read" text correctly the following variation
> should work, but it doesn't and additionally displays a "totally off" error
> message.
>
> $ echo "a b c d e f g" | \
> ( IFS=" " while read first remainder ;do echo "got $first" ;done )
> bash: syntax error near unexpected token `do'
Assignment statements may only precede simple commands, not compound
commands like `while'. The assignment prevents `while' from being
recognized as a reserved word. To do what you want, move the assignment
to IFS between the `while' and `read'.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet )
Live Strong.
Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/