From 8fe815e4c1e70e6774ebfa30ff8c50e86f72a2c1 Mon Sep 17 00:00:00 2001 From: Jonas Maier <> Date: Sun, 19 Apr 2026 12:13:35 +0200 Subject: alias: parses more than the first word in each argument --- src/parse/mod.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/parse') 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 { + fn parse(b: &mut Cursor<'_>) -> Result { + 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 { pub cmd: T::Str, @@ -1036,7 +1051,12 @@ pub fn completion_context(x: &[u8], e: &mut E) -> CompletionContext pub trait Parse: Sized { fn parse(b: &mut Cursor<'_>) -> Result; fn parse_from_bytes(x: &[u8]) -> Result { - 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) } } -- cgit v1.2.3