More edge case work

This commit is contained in:
2025-03-07 21:02:26 -05:00
parent 5c9031548a
commit eccdafb11e
9 changed files with 113 additions and 68 deletions

View File

@@ -4,9 +4,9 @@ pub mod alias;
pub mod cmdsub;
pub mod arithmetic;
use arithmetic::expand_arithmetic;
use arithmetic::expand_arith_token;
use vars::{expand_string, expand_var};
use tilde::expand_tilde;
use tilde::expand_tilde_token;
use crate::prelude::*;
@@ -23,9 +23,11 @@ pub fn expand_argv(argv: Vec<Token>, shenv: &mut ShEnv) -> ShResult<Vec<Token>>
pub fn expand_token(token: Token, shenv: &mut ShEnv) -> ShResult<Vec<Token>> {
let mut processed = vec![];
log!(INFO, "expanding argv");
log!(INFO, "rule: {:?}", token.rule());
match token.rule() {
TkRule::DQuote => {
let dquote_exp = expand_string(token.as_raw(shenv), shenv);
let dquote_exp = expand_string(&token.as_raw(shenv), shenv);
let mut expanded = shenv.expand_input(&dquote_exp, token.span());
processed.append(&mut expanded);
}
@@ -34,11 +36,11 @@ pub fn expand_token(token: Token, shenv: &mut ShEnv) -> ShResult<Vec<Token>> {
processed.append(&mut varsub_exp);
}
TkRule::TildeSub => {
let tilde_exp = expand_tilde(token.clone(), shenv);
let tilde_exp = expand_tilde_token(token.clone(), shenv);
processed.push(tilde_exp);
}
TkRule::ArithSub => {
let arith_exp = expand_arithmetic(token.clone(), shenv)?;
let arith_exp = expand_arith_token(token.clone(), shenv)?;
processed.push(arith_exp);
}
_ => {