help-bash
[Top][All Lists]
Advanced

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

What code make both `cat < /tmp/1.txt` and `< /tmp/1.txt cat` valid?


From: Peng Yu
Subject: What code make both `cat < /tmp/1.txt` and `< /tmp/1.txt cat` valid?
Date: Mon, 10 May 2021 10:31:04 -0500

I am trying to understand how bash is implemented

$ seq 3 > /tmp/1.txt
$ cat < /tmp/1.txt
1
2
3
$ < /tmp/1.txt cat
1
2
3

https://git.savannah.gnu.org/cgit/bash.git/tree/parse.y#n729

I see `redirection_list` is just a list of redirection.

redirection_list: redirection
        |       redirection_list redirection

But then it should be following `shell_command`. How come
redirection_list can be anywhere in a command including the beginning?

command:        
...
        |       shell_command redirection_list

-- 
Regards,
Peng



reply via email to

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