diff options
| author | Danilo M. <danix@danix.xyz> | 2026-05-06 10:03:38 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-05-06 10:03:38 +0200 |
| commit | 003ae4b80e61adab4571b42142adfb92816a9dd5 (patch) | |
| tree | 8e20b425f7dce04a99eb2b97326305b330cb7a67 | |
| parent | 4b2ffd1003531ef54396d1eb14a8b699d20073fc (diff) | |
| download | dots-backup-003ae4b80e61adab4571b42142adfb92816a9dd5.tar.gz dots-backup-003ae4b80e61adab4571b42142adfb92816a9dd5.zip | |
Fix remaining review issues: quoting and clear behaviour
- Quote $WORKDIR in all cd calls
- Quote ${HOME}/$i and $i in -f/-d test expressions
- Guard clear with QUIET check to avoid wiping terminal in scripted use
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
| -rwxr-xr-x | dot-backup.sh | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/dot-backup.sh b/dot-backup.sh index 4cee3fa..dd41199 100755 --- a/dot-backup.sh +++ b/dot-backup.sh @@ -274,7 +274,7 @@ do_restore() { # ── MAIN ────────────────────────────────────────────────────────────────────── -clear +if [[ "$QUIET" == false ]]; then clear; fi if [[ "$FIRST_RUN" == true ]]; then echo -e "${GREEN}First run — config directories created:${NC}" @@ -332,7 +332,7 @@ if [[ -n "$GIT_REMOTE" && "$DRY_RUN" == false ]]; then echo -e "${YELLOW}Adding remote origin: $GIT_REMOTE${NC}" git remote add origin "$GIT_REMOTE" fi - cd $WORKDIR + cd "$WORKDIR" fi if [[ "$DRY_RUN" == false ]]; then @@ -340,23 +340,23 @@ if [[ "$DRY_RUN" == false ]]; then fi echo -e $NC -cd $WORKDIR +cd "$WORKDIR" # we iterate all dotfiles in the list for i in "${DOTFILES[@]}"; do # if it's a file in my home - if [[ -f ${HOME}/$i ]]; then + if [[ -f "${HOME}/$i" ]]; then echo -e "${GREEN}${HOME}/$i${NC}" do_rsync "${HOME}/$i" "${DEFAULT_OUTPUT_DIR}/home/$i" # if it's a directory in my home - elif [[ -d ${HOME}/$i ]]; then + elif [[ -d "${HOME}/$i" ]]; then echo -e "${BLUE}${HOME}/$i${NC}" do_rsync "${HOME}/$i" "${DEFAULT_OUTPUT_DIR}/home/$i" true # if it begins with a / it's a system file/directory elif beginswith "/" "$i"; then - if [[ -f $i ]]; then + if [[ -f "$i" ]]; then echo -e "${GREEN}$i${NC}" do_rsync "$i" "${DEFAULT_OUTPUT_DIR}/system/${i#/}" - elif [[ -d $i ]]; then + elif [[ -d "$i" ]]; then echo -e "${BLUE}$i${NC}" do_rsync "$i" "${DEFAULT_OUTPUT_DIR}/system/${i#/}" true fi @@ -393,6 +393,6 @@ if [[ "$PUSH" == true ]]; then fi echo -e $NC -cd $WORKDIR +cd "$WORKDIR" if [[ "$QUIET" == true ]]; then echo "Log written to: $LOG_FILE" >&3; fi exit 0 |
