diff mbox series

libgo: Avoid clobbering shell history file in signal_cgo_test.go

Message ID mvm7epn3yzu.fsf@suse.de
State New
Headers show
Series libgo: Avoid clobbering shell history file in signal_cgo_test.go | expand

Commit Message

Andreas Schwab April 4, 2018, 1:03 p.m. UTC
For some reason signal_cgo_test.go needs to run an interactive shell,
but suppresses reading the startup files.  This causes the shell history
file to be clobbered, by using different history settings than usual.
Avoid that by setting HOME to / so that the shell cannot write a history
file.

	* libgo/go/os/signal/signal_cgo_test.go: Set HOME to / before
	starting shell.
---
 libgo/go/os/signal/signal_cgo_test.go | 1 +
 1 file changed, 1 insertion(+)

Comments

Ian Lance Taylor April 17, 2018, 11:55 p.m. UTC | #1
On Wed, Apr 4, 2018 at 6:03 AM, Andreas Schwab <schwab@suse.de> wrote:
>
> For some reason signal_cgo_test.go needs to run an interactive shell,
> but suppresses reading the startup files.  This causes the shell history
> file to be clobbered, by using different history settings than usual.
> Avoid that by setting HOME to / so that the shell cannot write a history
> file.

Thanks.  This has already been fixed in a different way in the master
libgo sources, so I've just copied that change into gccgo.
Bootstrapped and ran os/signal test on x86_64-pc-linux-gnu.  Committed
to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE	(revision 259445)
+++ gcc/go/gofrontend/MERGE	(working copy)
@@ -1,4 +1,4 @@
-2c7093358e5f5ebeb102d44d1036ca0a807d46a5
+b367349d85f315e94e10ee2d76a7c6a46b993dcb
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: libgo/go/os/signal/signal_cgo_test.go
===================================================================
--- libgo/go/os/signal/signal_cgo_test.go	(revision 259359)
+++ libgo/go/os/signal/signal_cgo_test.go	(working copy)
@@ -89,6 +89,8 @@ func TestTerminalSignal(t *testing.T) {
 	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
 	defer cancel()
 	cmd := exec.CommandContext(ctx, bash, "--norc", "--noprofile", "-i")
+	// Clear HISTFILE so that we don't read or clobber the user's bash history.
+	cmd.Env = append(os.Environ(), "HISTFILE=")
 	cmd.Stdin = slave
 	cmd.Stdout = slave
 	cmd.Stderr = slave
diff mbox series

Patch

diff --git a/libgo/go/os/signal/signal_cgo_test.go b/libgo/go/os/signal/signal_cgo_test.go
index 84a2a08ce9..3c127378d2 100644
--- a/libgo/go/os/signal/signal_cgo_test.go
+++ b/libgo/go/os/signal/signal_cgo_test.go
@@ -88,6 +88,7 @@  func TestTerminalSignal(t *testing.T) {
 	// Start an interactive shell.
 	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
 	defer cancel()
+	os.Setenv("HOME", "/")
 	cmd := exec.CommandContext(ctx, bash, "--norc", "--noprofile", "-i")
 	cmd.Stdin = slave
 	cmd.Stdout = slave