[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: What does `echo xxx 1>&2xxx` do?
From: |
Peng Yu |
Subject: |
Re: What does `echo xxx 1>&2xxx` do? |
Date: |
Sat, 8 May 2021 07:20:34 -0500 |
OK. I see.
How the parsing is done?
The shell grammar seems to be extremely context-sensitive.
http://aosabook.org/en/bash.html
The above link mentions metacharacters and words.
So in "1>&2xxx", 2xxx is recognized as a word?
In "1>&2", "2" is also recognized as a word? "1" is recognized as a word?
What about "1 >&2"? "1" is recognized as a word as well? How does bash
knows "1 >&2" and "1>&2" are actually different?
On 5/7/21, Koichi Murase <myoga.murase@gmail.com> wrote:
> 2021年5月8日(土) 11:57 Peng Yu <pengyu.ut@gmail.com>:
>> I see `echo xxx 1>&2xxx` generates no error messages, nor returns an
>> error status. Is this correct? Thanks.
>
> It is interpreted as "1>& FILENAME" where FILENAME is `2xxx', which is
> the deprecated form of "&> FILENAME" described in Manual 3.6.4.
>
> https://www.gnu.org/software/bash/manual/bash.html#Redirecting-Standard-Output-and-Standard-Error
>> 3.6.4 Redirecting Standard Output and Standard Error
>>
>> This construct allows both the standard output (file descriptor 1)
>> and the standard error output (file descriptor 2) to be redirected
>> to the file whose name is the expansion of word.
>>
>> There are two formats for redirecting standard output and standard
>> error:
>>
>> &>word
>>
>> and
>>
>> >&word
>
--
Regards,
Peng
- What does `echo xxx 1>&2xxx` do?, Peng Yu, 2021/05/07
- Re: What does `echo xxx 1>&2xxx` do?, Koichi Murase, 2021/05/07
- Re: What does `echo xxx 1>&2xxx` do?,
Peng Yu <=
- Re: What does `echo xxx 1>&2xxx` do?, Koichi Murase, 2021/05/08
- Re: What does `echo xxx 1>&2xxx` do?, Peng Yu, 2021/05/08
- Re: What does `echo xxx 1>&2xxx` do?, Chet Ramey, 2021/05/08
- Re: What does `echo xxx 1>&2xxx` do?, Peng Yu, 2021/05/08
- Re: What does `echo xxx 1>&2xxx` do?, Chet Ramey, 2021/05/08