From f95cdfd7d71586168bb62d653fd8d74100b97791 Mon Sep 17 00:00:00 2001 From: rsteube Date: Fri, 11 Aug 2023 09:07:46 +0200 Subject: [PATCH] split: redirects should only be filtered for pipelines --- action.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/action.go b/action.go index 7fcd53c3..be1306e6 100644 --- a/action.go +++ b/action.go @@ -281,12 +281,15 @@ func (a Action) split(pipelines bool) Action { return ActionMessage(err.Error()) } + var context Context if pipelines { tokens = tokens.CurrentPipeline() + context = NewContext(tokens.FilterRedirects().Words().Strings()...) + } else { + context = NewContext(tokens.Words().Strings()...) } originalValue := c.Value - context := NewContext(tokens.FilterRedirects().Words().Strings()...) prefix := originalValue[:tokens.Words().CurrentToken().Index] c.Args = context.Args c.Parts = []string{} @@ -306,9 +309,9 @@ func (a Action) split(pipelines bool) Action { if !invoked.meta.Nospace.Matches(value.Value) || strings.Contains(value.Value, " ") { // TODO special characters switch tokens.CurrentToken().State { case shlex.QUOTING_ESCAPING_STATE: - invoked.rawValues[index].Value = fmt.Sprintf(`"%v"`, strings.Replace(value.Value, `"`, `\"`, -1)) + invoked.rawValues[index].Value = fmt.Sprintf(`"%v"`, strings.ReplaceAll(value.Value, `"`, `\"`)) case shlex.QUOTING_STATE: - invoked.rawValues[index].Value = fmt.Sprintf(`'%v'`, strings.Replace(value.Value, `'`, `'"'"'`, -1)) + invoked.rawValues[index].Value = fmt.Sprintf(`'%v'`, strings.ReplaceAll(value.Value, `'`, `'"'"'`)) default: invoked.rawValues[index].Value = strings.Replace(value.Value, ` `, `\ `, -1) }