Skip to content

Commit

Permalink
syntax: run "confirm" shell commands in a temp dir
Browse files Browse the repository at this point in the history
Just in case they do anything that might leave a random file behind,
like a redirect that didn't fail like we expected it to.
  • Loading branch information
mvdan committed Jun 10, 2023
1 parent 829b814 commit 2c8e83c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions syntax/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,13 @@ func confirmParse(in, cmd string, wantErr bool) func(*testing.T) {
// -n makes bash accept invalid inputs like
// "let" or "`{`", so only use it in
// non-erroring tests. Should be safe to not use
// -n anyway since these are supposed to just
// fail.
// -n anyway since these are supposed to just fail.
// also, -n will break if we are using extglob
// as extglob is not actually applied.
opts = append(opts, "-n")
}
cmd := exec.Command(cmd, opts...)
cmd.Dir = t.TempDir() // to be safe
cmd.Stdin = strings.NewReader(in)
var stderr bytes.Buffer
cmd.Stderr = &stderr
Expand Down

0 comments on commit 2c8e83c

Please sign in to comment.