[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Parameter expansion/assignment broken in cat

From: Chet Ramey
Subject: Re: Parameter expansion/assignment broken in cat
Date: Tue, 31 Oct 2000 16:34:31 -0500

> Consider the following script sourced under Red Hat 7.0 and bash
> 2.04.11(1)-release:
>       unset foo
>       try=test
>       cat <<-.
>               ${foo:=$try}
>               value of foo: $foo"
>       .
>       echo $foo
> While it appears to behave normally, the assignment operator inside the
> cat statement seems to be broken. $foo is never really assigned the value
> "test," even though it displays it as such inside cat. The echo statement
> shows that the value has never truly been assigned to foo.
> What is causing this behavior?

The fact that you're running `cat', which is a command from the file system
and is executed in a subshell.  Redirections are performed in the subshell.

``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet)

Chet Ramey, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]