From 2c8e83c344e73c8355e40945837c26c74260b758 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Sat, 10 Jun 2023 22:42:56 +0100 Subject: [PATCH] syntax: run "confirm" shell commands in a temp dir 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. --- syntax/parser_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/syntax/parser_test.go b/syntax/parser_test.go index 52d545be..62916d99 100644 --- a/syntax/parser_test.go +++ b/syntax/parser_test.go @@ -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