aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/parse/mod.rs22
-rw-r--r--src/run/builtin.rs6
2 files changed, 24 insertions, 4 deletions
diff --git a/src/parse/mod.rs b/src/parse/mod.rs
index 184a514..88d0362 100644
--- a/src/parse/mod.rs
+++ b/src/parse/mod.rs
@@ -861,6 +861,21 @@ impl Parse for ExpString {
}
}
+impl Parse for Vec<ExpString> {
+ fn parse(b: &mut Cursor<'_>) -> Result<Self> {
+ let mut strings = Vec::new();
+ loop {
+ match ExpString::parse(b) {
+ Ok(s) => strings.push(s),
+ Err(ParseError::Eof) => break,
+ Err(ParseError::NotAString) => break,
+ Err(e) => Err(e)?,
+ }
+ }
+ Ok(strings)
+ }
+}
+
#[derive(Debug, Clone, PartialEq)]
pub struct Command<T: Stage> {
pub cmd: T::Str,
@@ -1036,7 +1051,12 @@ pub fn completion_context<E: Expander>(x: &[u8], e: &mut E) -> CompletionContext
pub trait Parse: Sized {
fn parse(b: &mut Cursor<'_>) -> Result<Self>;
fn parse_from_bytes(x: &[u8]) -> Result<Self> {
- Self::parse(&mut Cursor::new(x, ParseMode::Command))
+ let mut c = Cursor::new(x, ParseMode::Command);
+ let parsed = Self::parse(&mut c)?;
+ if c.has() {
+ return Err(ParseError::Unknown(c.buf[0]));
+ }
+ Ok(parsed)
}
}
diff --git a/src/run/builtin.rs b/src/run/builtin.rs
index f8c6c4c..7ca1e5e 100644
--- a/src/run/builtin.rs
+++ b/src/run/builtin.rs
@@ -487,9 +487,9 @@ impl Builtin for alias {
let mut parse_fail = false;
let mut alias_args = Vec::new();
for arg in args {
- match <crate::parse::ExpString as crate::parse::Parse>::parse_from_bytes(&arg[..]) {
- Ok(parsed) => {
- alias_args.push(parsed);
+ match <Vec<crate::parse::ExpString> as crate::parse::Parse>::parse_from_bytes(&arg[..]) {
+ Ok(mut parsed) => {
+ alias_args.append(&mut parsed);
}
Err(err) => {
writeln!(