[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: syntax error when setting variable in front of "while"
From: |
Dennis Williamson |
Subject: |
Re: syntax error when setting variable in front of "while" |
Date: |
Fri, 6 Aug 2010 13:16:57 -0500 |
while is a compound command. Only simple commands can have preceding
variable assignments. From man bash:
The environment for any simple command or function may be augmented
temporarily by prefixing it with parameter assignments, as described
above in PARAMETERS. These assignment statements affect only the envi‐
ronment seen by that command.
On Fri, Aug 6, 2010 at 5:40 AM, Ralf Goertz
<R_Goertz@usenet.arcornews.de> wrote:
>
> Bash Version: 4.0
> Patch Level: 35
> Release Status: release
>
> Description:
>
> I am used to setting variables in front of a command like in
>
>> LANG=C man mplayer
>
> However, I get a "bash: syntax error near unexpected token `do'" error
> when trying:
>
>> FOO=BAR while read a b; do echo $a $b; done
>
> Why? The similar
>
>> FOO=BAR read a b && echo $a $b
>
> works fine. (The problem occurred when I tried to temporarily set IFS to
> the tab character for a "read").
>
>
>