Skip to content

Commit

Permalink
fix: Fix panic when parsing some commands
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Jun 8, 2024
1 parent 588a157 commit f781976
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions internal/cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2863,13 +2863,16 @@ func parseCommand(command string, args []string) (string, []string, error) {
}); err != nil {
return "", nil, err
}
fields, err := expand.Fields(&expand.Config{
switch fields, err := expand.Fields(&expand.Config{
Env: expand.FuncEnviron(os.Getenv),
}, words...)
if err != nil {
}, words...); {
case err != nil:
return "", nil, err
case len(fields) > 1:
return fields[0], append(fields[1:], args...), nil
case len(fields) == 1:
return fields[0], args, nil
}
return fields[0], append(fields[1:], args...), nil
}

// Fallback to the command only.
Expand Down

0 comments on commit f781976

Please sign in to comment.