Skip to content

Commit

Permalink
Merge pull request #140 from rsteube/pwsh-fix-run
Browse files Browse the repository at this point in the history
run: fix pwsh by using a tempary file
  • Loading branch information
rsteube authored Feb 24, 2023
2 parents 5c60950 + ae82cff commit 7ed43d5
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion run.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,22 @@ func (r run) parse() func(cmd *cobra.Command, args []string) error {
return fmt.Errorf("unknown macro: %#v", matches[1])
}

mArgs = append(mArgs, "-c", matches[3], "--")
if mCmd != "pwsh" {
mArgs = append(mArgs, "-c", matches[3], "--")
} else {
// pwsh handles arguments after `-c` differently (https://github.com/PowerShell/PowerShell/issues/13832)
path, err := os.CreateTemp(os.TempDir(), "carapace-spec_run")
if err != nil {
return err
}
defer os.Remove(path.Name())

if err = os.WriteFile(path.Name(), []byte(matches[3]), 0700); err != nil {
return err
}
mArgs = append(mArgs, path.Name())

}

default:
return fmt.Errorf("malformed macro: %#v", r)
Expand Down

0 comments on commit 7ed43d5

Please sign in to comment.