help-bash
[Top][All Lists]
Advanced

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

Re: Why can redirection be combined in an assignment statement?


From: Chet Ramey
Subject: Re: Why can redirection be combined in an assignment statement?
Date: Mon, 10 May 2021 16:04:05 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.10.1

On 5/10/21 11:40 AM, Peng Yu wrote:
I can not see why redirection is allowed in an assignment statement.

Because there is nothing in the grammar that says that a simple command
has to contain a command word. In fact, in the POSIX grammar, which is a
little more complex in this case, there are clauses that explicitly allow
redirections and assignments to appear without a command word. A simple
command is composed of words, assignment statements (as long as they
precede any command word), and redirections. Any one of those three can be
omitted.


Is there a useful situation in which redirection does do something
useful in an assignment statement? If not, why not prompt an error for
this case?

Because it's not an error, regardless of whether or not you can imagine a
situation in which someone might use it.

Again, you're quibbling with decisions that were made 40 years ago and are
now standardized.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/



reply via email to

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