help-bash
[Top][All Lists]
Advanced

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

Re: Do `>& -` and `<& -` also work?


From: Chet Ramey
Subject: Re: Do `>& -` and `<& -` also work?
Date: Mon, 10 May 2021 15:41:13 -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 2:44 PM, Andreas Kusalananda Kähäri wrote:

Did you try your ">& ./-"?  I get

        $ echo hello >& ./-
        bash: ./: ambiguous redirect

This is an error because bash translates this into >&DIGIT- (which moves
file descriptors). The syntax is more general than it might seem, because
DIGIT can actually be a WORD that expands to a number. This is consistent
with the other redirection operators that take a WORD and bash's support
for multi-digit file descriptors. When it doesn't expand to a number, it's
a redirection error.

Chet
--
``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]