vte.sh warns on undefined BASH_VERSION, ZSH_VERSION under `set -u`
Debian user Marko Mäkelä writes:
At the start of my $HOME/.bashrc I have configured "set -u" to catch the use of undefined variables.
Whenever I open a new gnome-terminal window using bash as the shell, the script vte-2.91.sh will emit two messages about dereferencing an undefined variable ZSH_VERSION.
The script starts like this:
# Not bash or zsh? [ -n "$BASH_VERSION" -o -n "$ZSH_VERSION" ] || return 0 # Not an interactive shell? [[ $- == *i* ]] || return 0 # Not running under vte? [ "${VTE_VERSION:-0}" -ge 3405 ] || return 0
Note: for VTE_VERSION, the correct pattern is being used. I believe that that pattern is POSIX shell compliant; at least it works in /bin/dash.
and proposes this patch:
--- /etc/profile.d/vte-2.91.sh
+++ /etc/profile.d/vte-2.91.sh
@@ -15,7 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Not bash or zsh?
-[ -n "$BASH_VERSION" -o -n "$ZSH_VERSION" ] || return 0
+[ -n "${BASH_VERSION:-}" -o -n "${ZSH_VERSION:-}" ] || return 0
# Not an interactive shell?
[[ $- == *i* ]] || return 0
@@ -58,8 +58,8 @@
case "$TERM" in
xterm*|vte*)
- [ -n "$BASH_VERSION" ] && PROMPT_COMMAND="__vte_prompt_command"
- [ -n "$ZSH_VERSION" ] && precmd_functions+=(__vte_osc7)
+ [ -n "${BASH_VERSION:-}" ] && PROMPT_COMMAND="__vte_prompt_command"
+ [ -n "${ZSH_VERSION:-}" ] && precmd_functions+=(__vte_osc7)
;;
esac
Edited by Simon McVittie