From 64d04e717b001c58f60c57c472bcf406083eff4d Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Thu, 13 Aug 2020 23:04:29 +0100 Subject: [PATCH] Really stop affecting user command history (re: aff63e38) The fix was incomplete because some tests have to unset HISTFILE, which reverted them to using ~/.sh_history by default. src/cmd/ksh93/tests/shtests: - Instead of setting HISTFILE, set HOME to the temporary directory $tmp, so nothing will write to the real user directory and the default history file is $tmp/.sh_history. src/cmd/ksh93/tests/attributes.sh: - Restore HISTFILE after a test that requires setting HISTFILE=foo. --- src/cmd/ksh93/tests/attributes.sh | 2 ++ src/cmd/ksh93/tests/shtests | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cmd/ksh93/tests/attributes.sh b/src/cmd/ksh93/tests/attributes.sh index a6661fc31..ee4feee1d 100755 --- a/src/cmd/ksh93/tests/attributes.sh +++ b/src/cmd/ksh93/tests/attributes.sh @@ -408,10 +408,12 @@ typeset groupDB="" userDB="" typeset -l -L1 DBPick="" [[ -n "$groupDB" ]] && err_exit 'typeset -l -L1 causes unwanted side effect' +[[ -v HISTFILE ]] && saveHISTFILE=$HISTFILE || unset saveHISTFILE HISTFILE=foo typeset -u PS1='hello --- ' HISTFILE=foo [[ $HISTFILE == foo ]] || err_exit 'typeset -u PS1 affects HISTFILE' +[[ -v saveHISTFILE ]] && HISTFILE=$saveHISTFILE || unset HISTFILE typeset -a a=( aA= ZQ= bA= bA= bw= Cg= ) typeset -b x diff --git a/src/cmd/ksh93/tests/shtests b/src/cmd/ksh93/tests/shtests index 82ae4c76b..b5d413b2d 100755 --- a/src/cmd/ksh93/tests/shtests +++ b/src/cmd/ksh93/tests/shtests @@ -298,7 +298,8 @@ else trap 'cd / && rm -rf "$tmp"' EXIT fi # for interactive shell ('ksh -i') tests: avoid affecting ~/.sh_history -export HISTFILE=$tmp/sh_history +# (some tests must unset or modify $HISTFILE, so set $HOME instead) +export HOME=$tmp if (( compile )) then if whence $SHCOMP > /dev/null