Skip to content

Commit

Permalink
Merge pull request #893 from rsteube/split-redirect
Browse files Browse the repository at this point in the history
split: redirects should only be filtered for pipelines
  • Loading branch information
rsteube authored Aug 11, 2023
2 parents 517e083 + f95cdfd commit c89a442
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions action.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand All @@ -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)
}
Expand Down

0 comments on commit c89a442

Please sign in to comment.