|
myshell 2.0.0
|
Redirects related utilities. More...
Functions | |
| redirects_t | parse_redirects (tokens_t &tokens) |
| Parse redirects from command's tokens. | |
Redirects related utilities.
| redirects_t parse_redirects | ( | tokens_t & | tokens | ) |
Parse redirects from command's tokens.
The processing is done only on the tokens with the REDIRECT flag set.
The following redirects are supported: Redirecting output:
n>word - Open file word for writing on file descriptor n. If n is omitted, it defaults to 1.
Appending output:
n>>word - Open file word for appending on file descriptor n. If n is omitted, it defaults to 1.
Redirecting input:
n\<word - Open file word for reading on file descriptor n. If n is omitted, it defaults to 0.
Redirecting output and error:
&>word - Redirect both standard output and standard error to file word. Equivalent to >word 2>&1 and >&word.
Appending output and error:
&>>word - Append both standard output and standard error to file word. Semantically equivalent to >>word 2>&1.
Duplicating file descriptors:
n\<&word - The file descriptor n is made to be a copy of the descriptor specified by word. If word doesn't specify a descriptor, the redirection is ill-formed due to ambiguity. If n is not specified, the standard input (file descriptor 0) is used. If descriptor specified by word is not correct, the redirection error occurs.
n>&word - Used for duplicating output file descriptors. If n is not specified, the standard output (file descriptor 1) is used. If word doesn't specify a descriptor, it is interpreted as a filename to open. If the file descriptor specified by word is not correct, the redirection error occurs. If n is omitted, and word does not specify a file descriptor, the redirect is equivalent to &>word.
| tokens | The tokens to parse. |