Make shrc work with set -u

This commit is contained in:
Anthony Rose 2021-02-15 10:44:28 +00:00
parent 64b115d76e
commit 84c00d0562

View file

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
export ACP_SHRC=1 export ACP_SHRC=1
if [ "$ZSH_VERSION" ]; then if [ "${ZSH_VERSION-none}" != "none" ]; then
emulate sh -c 'source /etc/profile' emulate sh -c 'source /etc/profile'
fi fi
@ -128,19 +128,19 @@ export POWERSHELL_TELEMETRY_OPTOUT=1
export PYTHONWARNINGS="ignore::UserWarning" export PYTHONWARNINGS="ignore::UserWarning"
PS1="$ " PS1="$ "
if test -z "${HOST}"; then if [ "${HOST-invalid}" != "invalid" ]; then
HOST="$(hostname 2>/dev/null || cat /etc/hostname)" HOST="$(hostname 2>/dev/null || cat /etc/hostname)"
fi fi
if test $(id -u) -eq 0; then if test $(id -u) -eq 0; then
export PS1="${HOST%%.*}# " export PS1="${HOST-localhost%%.*}# "
else else
export PS1="${HOST%%.*}$ " export PS1="${HOST-localhost%%.*}$ "
fi fi
if test -x /usr/bin/tty; then if test -x /usr/bin/tty; then
export GPG_TTY=$(tty) export GPG_TTY=$(tty)
fi fi
if [ "$BASH" ]; then if [ "${BASH-none}" != "none" ]; then
HISTCONTROL=ignorespace:ignoredups HISTCONTROL=ignorespace:ignoredups
shopt -s histappend shopt -s histappend
bind '"\e[1;5C": forward-word' bind '"\e[1;5C": forward-word'
@ -157,7 +157,7 @@ if [ "$BASH" ]; then
fi fi
fi fi
if [ "$ZSH_VERSION" ]; then if [ "${ZSH_VERSION-none}" != "none" ]; then
# Command history. # Command history.
autoload -Uz compinit && compinit autoload -Uz compinit && compinit
autoload -U history-search-end autoload -U history-search-end