Make hishtory work with set -o nounset for bash and zsh, for #142 (#144)

This commit is contained in:
David Dworken 2023-12-10 09:14:12 -08:00 committed by GitHub
parent 0a81799609
commit 3a49c9c11f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -7,7 +7,7 @@ __hishtory_bash_config_sourced=`date`
# Implementation of running before/after every command based on https://jichu4n.com/posts/debug-trap-and-prompt_command-in-bash/
function __hishtory_precommand() {
if [ -z "$HISHTORY_AT_PROMPT" ]; then
if [ -z "${HISHTORY_AT_PROMPT:-}" ]; then
return
fi
unset HISHTORY_AT_PROMPT
@ -27,7 +27,7 @@ function __hishtory_postcommand() {
EXIT_CODE=$?
HISHTORY_AT_PROMPT=1
if [ -n "$HISHTORY_FIRST_PROMPT" ]; then
if [ -n "${HISHTORY_FIRST_PROMPT:-}" ]; then
unset HISHTORY_FIRST_PROMPT
return
fi

View File

@ -19,7 +19,7 @@ function _hishtory_precmd() {
# Runs after the command is executed in order to render the prompt
# $? contains the exit code
_hishtory_exit_code=$?
if [ -n "$_hishtory_first_prompt" ]; then
if [ -n "${_hishtory_first_prompt:-}" ]; then
unset _hishtory_first_prompt
return
fi