Reputation: 1183
I'm currently trying to re-code a shell in C using a BNF and LL parser.
Otherwise, I need to know what is the precedence of shell operator of
|
, <<
, ,
, <
, >>
, >
, &
, ;
?
Is there anyone who can provide me it ? Thank you
Upvotes: 7
Views: 5116
Reputation: 241911
<
, >
, >>
, <>
, <&
. >&
and >>-
, as well as here-docs <<delimiter
and here-strings <<<word
) are roughly the same as command-line arguments, and can appear anywhere in a simple command, including before the command word. Effectively, they bind most tightly, as with postfix operators in most languages.|
) are the strongest binary operator. They associate to the left.&&
and ||
). Unlike many languages, these have the same precedence. They also associate to the left.,
is not a bash operator. ;
and &
are statement terminators, not separators, although in some circumstances the final separator is optional. Effectively, they have the lowest precedence.
See the shell grammar for details. There are lots of details.
Upvotes: 15