summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2022-01-10 00:14:25 -0500
committerJesse Luehrs <doy@tozt.net>2022-01-10 00:14:25 -0500
commitfeb932105426a9c9f7ab861dbdf2c2ab813b1f6a (patch)
tree05d128d744e4104216f805305d30c5e97ce3e8df
parentf7ae4de810779c367f7d4cfa83c234ef138b44e0 (diff)
downloadnbsh-feb932105426a9c9f7ab861dbdf2c2ab813b1f6a.tar.gz
nbsh-feb932105426a9c9f7ab861dbdf2c2ab813b1f6a.zip
add more readable aliases for std fds
-rw-r--r--src/parse/ast.rs7
-rw-r--r--src/shell.pest4
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+ }