autojump
autojump copied to clipboard
Sources a custom install location twice
Hi,
When a custom install location is given to install.py
, it modifies autojump.sh
erroneously: it appends a new if
block at the end of the file, when it should instead include another elif
so that it does not potentially source the main shell file twice in case a distribution symlinks it into a standard location.
On a default Homebrew installation using /usr/local
prefix, this is the resulting autojump.sh
symlinked at /usr/local/etc/profile.d/autojump.sh
after installation:
# the login $SHELL isn't always the one used
# NOTE: problems might occur if /bin/sh is symlinked to /bin/bash
if [ -n "${BASH}" ]; then
shell="bash"
elif [ -n "${ZSH_NAME}" ]; then
shell="zsh"
elif [ -n "${__fish_datadir}" ]; then
shell="fish"
elif [ -n "${version}" ]; then
shell="tcsh"
else
shell=$(echo ${SHELL} | awk -F/ '{ print $NF }')
fi
# prevent circular loop for sh shells
if [ "${shell}" = "sh" ]; then
return 0
# check local install
elif [ -s ~/.autojump/share/autojump/autojump.${shell} ]; then
source ~/.autojump/share/autojump/autojump.${shell}
# check global install
elif [ -s /usr/local/share/autojump/autojump.${shell} ]; then
source /usr/local/share/autojump/autojump.${shell}
fi
# check custom install
if [ -s /usr/local/Cellar/autojump/22.5.3/share/autojump/autojump.${shell} ]; then
source /usr/local/Cellar/autojump/22.5.3/share/autojump/autojump.${shell}
fi
The Homebrew installation does create symlinks at /usr/local/share/autojump/autojump.${shell}
, so because the "check custom install" block is not an elif
, it sources twice and essentially doubles autojump's load time in shell startup.