From 761fc17935db0453ec463d2f4279710f016e0b1a Mon Sep 17 00:00:00 2001 From: Jon B Date: Fri, 10 Apr 2026 11:04:20 -0500 Subject: [PATCH 1/2] fix(installer): robust legacy migration and cleanup - Fix order of operations in install.bash to migrate AFTER asset copying - Ensure rsync --delete does not wipe user's custom modules during upgrade - Clean up .DS_Store artifacts --- assets/.DS_Store | Bin 6148 -> 0 bytes install.bash | 47 +++++++++++++++++++++++++++++++++++++---------- 2 files changed, 37 insertions(+), 10 deletions(-) delete mode 100644 assets/.DS_Store diff --git a/assets/.DS_Store b/assets/.DS_Store deleted file mode 100644 index 2c6aaf4b381f8ed008de5f5e69e356c59222defa..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK%}T>S5T2UW_G^ah>OCSb_xvLpUxw*D;T#UL-Lc?||} zf4sjwb6#bct)CpdK0ZA>zZ`#sJ^co|zFfNN!@k_Sn=9Z7xB`Dy0n}`g~M4o>z{{Qv*} diff --git a/install.bash b/install.bash index 8c8a23b..372ccfa 100755 --- a/install.bash +++ b/install.bash @@ -515,20 +515,45 @@ if [[ "$DRY_RUN" -eq 1 ]]; then echo " Installers: ${INSTALLS:-}" fi -mkdir -p "$PREFIX" -export GET_BASHED_HOME="$PREFIX" -export GET_BASHED_VIMRC_MODE="$VIMRC_MODE" +# @internal +migrate_legacy() { + local legacy_rc_d="$HOME/.bashrc.d" + local legacy_secrets_d="$HOME/.secrets.d" + + if [[ -d "$legacy_rc_d" && ! -L "$legacy_rc_d" ]]; then + echo "Migrating legacy .bashrc.d to $PREFIX/bashrc.d..." + mkdir -p "$PREFIX/bashrc.d" + # Copy files, avoid error if empty + find "$legacy_rc_d" -type f -exec cp -p {} "$PREFIX/bashrc.d/" \; + rm -rf "$legacy_rc_d" + fi -copy_tree() { - local src="$1" dest="$2" - mkdir -p "$dest" - if [[ "${FORCE:-0}" -eq 1 ]]; then - rsync -a --delete "$src"/ "$dest"/ - else - rsync -a "$src"/ "$dest"/ + if [[ -d "$legacy_secrets_d" && ! -L "$legacy_secrets_d" ]]; then + echo "Migrating legacy .secrets.d to $PREFIX/secrets.d..." + mkdir -p "$PREFIX/secrets.d" + chmod 700 "$PREFIX/secrets.d" + find "$legacy_secrets_d" -type f -exec cp -p {} "$PREFIX/secrets.d/" \; + rm -rf "$legacy_secrets_d" fi + + # Detect and fix "template as file" loop hazard + for f in "$HOME/.bashrc" "$HOME/.bash_profile"; do + if [[ -f "$f" && ! -L "$f" ]]; then + if grep -q "@file bashrc" "$f" || grep -q "@file bash_profile" "$f"; then + if [[ "$LINK_DOTFILES" -eq 0 ]]; then + echo "Detected recursive loop hazard in $f. Cleaning..." + backup_file "$f" + echo "# get-bashed: recovered from loop" > "$f" + fi + fi + fi + done } +mkdir -p "$PREFIX" +export GET_BASHED_HOME="$PREFIX" +export GET_BASHED_VIMRC_MODE="$VIMRC_MODE" + # Copy base assets copy_tree "$REPO_DIR/bashrc.d" "$PREFIX/bashrc.d" cp -f "$REPO_DIR/bashrc" "$PREFIX/bashrc" @@ -538,6 +563,8 @@ cp -f "$REPO_DIR/inputrc" "$PREFIX/inputrc" cp -f "$REPO_DIR/vimrc" "$PREFIX/vimrc" cp -f "$REPO_DIR/gitconfig" "$PREFIX/gitconfig" +migrate_legacy + # secrets.d bootstrap (only inside GET_BASHED_HOME) mkdir -p "$PREFIX/secrets.d" chmod 700 "$PREFIX/secrets.d" From 0732751df40b6771301ec699a3d772dc3b9d6797 Mon Sep 17 00:00:00 2001 From: Jon B Date: Fri, 10 Apr 2026 11:09:14 -0500 Subject: [PATCH 2/2] fix(installer): restore copy_tree and fix corrupted syntax --- install.bash | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/install.bash b/install.bash index 372ccfa..44a364c 100755 --- a/install.bash +++ b/install.bash @@ -19,7 +19,7 @@ fi usage() { cat <<'USAGE' Usage: install.sh [--prefix PATH] [--force] [--with-ui] - [--auto] [--yes] + [--auto] [--yes] [--profiles minimal|dev|ops[,..]] [--features gnu_over_bsd,build_flags,...] [--install brew,asdf,doppler,...] @@ -71,7 +71,7 @@ GET_BASHED_GIT_SIGNING=0 while [[ $# -gt 0 ]]; do case "$1" in - --prefix) + --prefix) if [[ $# -lt 2 ]]; then echo "Error: --prefix requires a value" >&2 usage @@ -554,6 +554,16 @@ mkdir -p "$PREFIX" export GET_BASHED_HOME="$PREFIX" export GET_BASHED_VIMRC_MODE="$VIMRC_MODE" +copy_tree() { + local src="$1" dest="$2" + mkdir -p "$dest" + if [[ "${FORCE:-0}" -eq 1 ]]; then + rsync -a --delete "$src"/ "$dest"/ + else + rsync -a "$src"/ "$dest"/ + fi +} + # Copy base assets copy_tree "$REPO_DIR/bashrc.d" "$PREFIX/bashrc.d" cp -f "$REPO_DIR/bashrc" "$PREFIX/bashrc" @@ -624,10 +634,10 @@ else # shellcheck disable=SC2016 BASHRC_LINE="# get-bashed: source modular bashrc" # shellcheck disable=SC2016 -BASHRC_SNIP='if [[ -r "$HOME/.get-bashed/bashrc" ]]; then source "$HOME/.get-bashed/bashrc"; fi' +BASHRC_SNIP="if [[ -r \"$PREFIX/bashrc\" ]]; then source \"$PREFIX/bashrc\"; fi" BASH_PROFILE_LINE="# get-bashed: source login bash_profile" # shellcheck disable=SC2016 -BASH_PROFILE_SNIP='if [[ -r "$HOME/.get-bashed/bash_profile" ]]; then source "$HOME/.get-bashed/bash_profile"; fi' +BASH_PROFILE_SNIP="if [[ -r \"$PREFIX/bash_profile\" ]]; then source \"$PREFIX/bash_profile\"; fi" ensure_block "$HOME/.bashrc" "$BASHRC_LINE" "$BASHRC_SNIP" ensure_block "$HOME/.bash_profile" "$BASH_PROFILE_LINE" "$BASH_PROFILE_SNIP"