Skip to content

Commit

Permalink
Merge pull request #142 from rsteube/run-alias-no-subst
Browse files Browse the repository at this point in the history
run: skip envsubst for alias
  • Loading branch information
rsteube authored Feb 24, 2023
2 parents 78fe257 + a90d721 commit 0ef00dc
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions run.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func (r run) parse() func(cmd *cobra.Command, args []string) error {
return func(cmd *cobra.Command, args []string) error {
mCmd := ""
mArgs := make([]string, 0)
alias := false

switch {
case strings.HasPrefix(string(r), "["):
Expand All @@ -32,6 +33,7 @@ func (r run) parse() func(cmd *cobra.Command, args []string) error {

mCmd = mArgs[0]
mArgs = mArgs[1:]
alias = true

case strings.HasPrefix(string(r), "$"):
matches := regexp.MustCompile(`^\$(?P<macro>[^(]*)(\((?P<arg>.*)\))?$`).FindStringSubmatch(string(r))
Expand Down Expand Up @@ -85,11 +87,13 @@ func (r run) parse() func(cmd *cobra.Command, args []string) error {
context.Setenv(fmt.Sprintf("C_FLAG_%v", strings.ToUpper(f.Name)), f.Value.String())
}
})
var err error
for index, mArg := range mArgs {
mArgs[index], err = context.Envsubst(mArg)
if err != nil {
return err
if !alias {
var err error
for index, mArg := range mArgs {
mArgs[index], err = context.Envsubst(mArg)
if err != nil {
return err
}
}
}

Expand Down

0 comments on commit 0ef00dc

Please sign in to comment.