From f3c36f1afb0a3e5df82fb6fc9982a255929c97f8 Mon Sep 17 00:00:00 2001 From: Ryan Wilson Date: Sun, 16 Aug 2026 00:05:01 -0500 Subject: [PATCH 1/2] Scrub stale bitsentry shell alias during install The installer runs under bash, so it has no visibility into zsh/fish alias tables -- a leftover alias bitsentry='/some/old/path' (from an earlier version of this script, or copied in via dotfiles) silently shadows the real launcher in interactive shells even after a completely successful install. Now strips any 'alias bitsentry=' line from the managed rc file before finishing, so "install complete" actually means the command works. --- scripts/install_bitsentry.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/scripts/install_bitsentry.sh b/scripts/install_bitsentry.sh index 9e2a9bf..5de5175 100755 --- a/scripts/install_bitsentry.sh +++ b/scripts/install_bitsentry.sh @@ -256,6 +256,22 @@ else fi rm -f "${LAUNCHER_TMP}" +# A shell alias named `bitsentry` (e.g. left over from an older version of +# this installer, or copied in via synced dotfiles from another machine) +# shadows the real launcher in interactive shells even though this script +# -- running under bash -- has no visibility into zsh/fish alias tables to +# detect that itself. Scrub it from the rc file we're about to manage so +# "install completed" actually means the command works. +if [[ -n "${RC_FILE}" ]] && [[ -f "${RC_FILE}" ]] && grep -qE '^[[:space:]]*alias[[:space:]]+bitsentry=' "${RC_FILE}"; then + echo "[!] Found an existing 'bitsentry' alias in ${RC_FILE} that would shadow the installed launcher." + if [[ "${OS_NAME}" == "Darwin" ]]; then + sed -i '' '/^[[:space:]]*alias[[:space:]]\+bitsentry=/d' "${RC_FILE}" + else + sed -i '/^[[:space:]]*alias[[:space:]]\+bitsentry=/d' "${RC_FILE}" + fi + echo "[+] Removed stale bitsentry alias from ${RC_FILE}" +fi + if [[ "${OS_NAME}" == "Darwin" ]] && [[ "${INSTALL_BIN_PATH}" == *"/sbin/"* ]]; then MAC_BIN="/usr/local/bin/bitsentry" if [[ ! -f "${MAC_BIN}" ]] || [[ "${INSTALL_BIN_PATH}" -nt "${MAC_BIN}" ]] 2>/dev/null; then From 9d7d1039fadf57b4c5d3a5ef60cd2f1db1a0b865 Mon Sep 17 00:00:00 2001 From: Ryan Wilson Date: Sun, 16 Aug 2026 00:33:48 -0500 Subject: [PATCH 2/2] Only auto-remove provably standalone bitsentry aliases The previous fix deleted the whole matching line, which would have silently destroyed unrelated content on a compound (;), conditional (&&), or line-continuation (\) alias declaration sharing that line. Now only deletes a line if it's provably nothing but a standalone alias bitsentry=... declaration; anything else is left alone and reported so the user can clean it up by hand. Verified against 6 cases: standalone single/double-quoted (deleted), compound semicolon / conditional && / line continuation (all left untouched, all warned), and no-alias-present (no-op). --- scripts/install_bitsentry.sh | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/scripts/install_bitsentry.sh b/scripts/install_bitsentry.sh index 5de5175..fc42bdc 100755 --- a/scripts/install_bitsentry.sh +++ b/scripts/install_bitsentry.sh @@ -262,14 +262,27 @@ rm -f "${LAUNCHER_TMP}" # -- running under bash -- has no visibility into zsh/fish alias tables to # detect that itself. Scrub it from the rc file we're about to manage so # "install completed" actually means the command works. -if [[ -n "${RC_FILE}" ]] && [[ -f "${RC_FILE}" ]] && grep -qE '^[[:space:]]*alias[[:space:]]+bitsentry=' "${RC_FILE}"; then - echo "[!] Found an existing 'bitsentry' alias in ${RC_FILE} that would shadow the installed launcher." - if [[ "${OS_NAME}" == "Darwin" ]]; then - sed -i '' '/^[[:space:]]*alias[[:space:]]\+bitsentry=/d' "${RC_FILE}" - else - sed -i '/^[[:space:]]*alias[[:space:]]\+bitsentry=/d' "${RC_FILE}" +# +# Only delete a line if it's PROVABLY just a standalone `alias bitsentry=...` +# declaration -- the whole line, nothing else. A line sharing `; other-cmd`, +# `&& other-cmd`, a leading conditional, or a trailing `\` continuation gets +# left alone; deleting the whole line would silently destroy that unrelated +# content too. Those get reported for manual cleanup instead. +BITSENTRY_ALIAS_RE='alias[[:space:]]+bitsentry=' +BITSENTRY_ALIAS_STANDALONE_RE='^[[:space:]]*alias[[:space:]]+bitsentry=("[^"]*"|'"'"'[^'"'"']*'"'"'|[^[:space:];&|\\]+)[[:space:]]*$' +if [[ -n "${RC_FILE}" ]] && [[ -f "${RC_FILE}" ]] && grep -qE "${BITSENTRY_ALIAS_RE}" "${RC_FILE}"; then + if grep -qE "${BITSENTRY_ALIAS_STANDALONE_RE}" "${RC_FILE}"; then + echo "[!] Found an existing 'bitsentry' alias in ${RC_FILE} that would shadow the installed launcher." + if [[ "${OS_NAME}" == "Darwin" ]]; then + sed -i '' -E "/${BITSENTRY_ALIAS_STANDALONE_RE}/d" "${RC_FILE}" + else + sed -i -E "/${BITSENTRY_ALIAS_STANDALONE_RE}/d" "${RC_FILE}" + fi + echo "[+] Removed stale bitsentry alias from ${RC_FILE}" + fi + if grep -qE "${BITSENTRY_ALIAS_RE}" "${RC_FILE}"; then + echo "[!] ${RC_FILE} still defines a 'bitsentry' alias on a compound, conditional, or continued line -- it may shadow the installed launcher. Please remove it manually." fi - echo "[+] Removed stale bitsentry alias from ${RC_FILE}" fi if [[ "${OS_NAME}" == "Darwin" ]] && [[ "${INSTALL_BIN_PATH}" == *"/sbin/"* ]]; then