From 55d47f6d90dadf1c54ced19d547b1a7a11cb2b30 Mon Sep 17 00:00:00 2001 From: pagedmov Date: Mon, 23 Feb 2026 21:16:29 -0500 Subject: [PATCH] Added more accurate logic for @ expansion --- src/expand.rs | 7 ++++++- src/state.rs | 12 +++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/expand.rs b/src/expand.rs index 1eb14a8..29e9642 100644 --- a/src/expand.rs +++ b/src/expand.rs @@ -37,6 +37,8 @@ pub const PROC_SUB_OUT: char = '\u{fdd6}'; /// which breaks some commands pub const NULL_EXPAND: char = '\u{fdd7}'; +pub const ARG_SEP: char = '\u{fdd8}'; + impl Tk { /// Create a new expanded token pub fn expand(self) -> ShResult { @@ -104,6 +106,9 @@ impl Expander { DUB_QUOTE | SNG_QUOTE | SUBSH => { while let Some(q_ch) = chars.next() { match q_ch { + ARG_SEP if ch == DUB_QUOTE => { + words.push(mem::take(&mut cur_word)); + } _ if q_ch == ch => { was_quoted = true; continue 'outer; // Isn't rust cool @@ -112,7 +117,7 @@ impl Expander { } } } - _ if is_field_sep(ch) => { + _ if is_field_sep(ch) || ch == ARG_SEP => { if cur_word.is_empty() && !was_quoted { cur_word.clear(); } else { diff --git a/src/state.rs b/src/state.rs index 27e7bc1..8784a35 100644 --- a/src/state.rs +++ b/src/state.rs @@ -10,16 +10,10 @@ use std::{ use nix::unistd::{User, gethostname, getppid}; use crate::{ - builtin::trap::TrapTarget, - exec_input, - jobs::JobTab, - libsh::{ + builtin::trap::TrapTarget, exec_input, expand::ARG_SEP, jobs::JobTab, libsh::{ error::{ShErr, ShErrKind, ShResult}, utils::VecDequeExt, - }, - parse::{ConjunctNode, NdRule, Node, ParsedSrc}, - prelude::*, - shopt::ShOpts, + }, parse::{ConjunctNode, NdRule, Node, ParsedSrc}, prelude::*, shopt::ShOpts }; pub struct Fern { @@ -603,7 +597,7 @@ impl VarTab { fn update_arg_params(&mut self) { self.set_param( ShellParam::AllArgs, - &self.sh_argv.clone().to_vec()[1..].join(" "), + &self.sh_argv.clone().to_vec()[1..].join(&ARG_SEP.to_string()), ); self.set_param(ShellParam::ArgCount, &(self.sh_argv.len() - 1).to_string()); }