From feb932105426a9c9f7ab861dbdf2c2ab813b1f6a Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Mon, 10 Jan 2022 00:14:25 -0500 Subject: add more readable aliases for std fds --- src/parse/ast.rs | 7 ++++++- src/shell.pest | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/parse/ast.rs b/src/parse/ast.rs index 37e7fe0..4c65c6a 100644 --- a/src/parse/ast.rs +++ b/src/parse/ast.rs @@ -242,7 +242,12 @@ impl Redirect { super::Direction::Out | super::Direction::Append => 1, } } else { - from.parse().unwrap() + match from { + "in" => 0, + "out" => 1, + "err" => 2, + _ => from.parse().unwrap(), + } }; Self { from, to, dir } } diff --git a/src/shell.pest b/src/shell.pest index 4c5f728..dc3f247 100644 --- a/src/shell.pest +++ b/src/shell.pest @@ -14,7 +14,9 @@ var = @{ ("${" ~ (!"}" ~ ANY)+ ~ "}") } -redir_prefix = @{ ASCII_DIGIT* ~ (">>" | ">" | "<") ~ WHITESPACE* } +redir_prefix = @{ + ("in" | "out" | "err" | ASCII_DIGIT*) ~ (">>" | ">" | "<") ~ WHITESPACE* +} bareword = @{ bareword_char+ } single_string = @{ single_string_char+ } double_string = @{ double_string_char+ } -- cgit v1.2.3-54-g00ecf