Added more accurate logic for @ expansion
This commit is contained in:
@@ -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<Self> {
|
||||
@@ -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 {
|
||||
|
||||
12
src/state.rs
12
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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user