diff options
| author | Danilo M. <danix@danix.xyz> | 2026-06-16 18:46:06 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-06-16 18:46:06 +0200 |
| commit | 3aaaf1753d8aa444fda44064ff2c655c5788cb25 (patch) | |
| tree | 7b392fd5193d3d972b4608a6da5dc81361a6a31a /dot-backup.sh | |
| parent | b3568ae80439223b3b313bdc3bfad4edc5c7f939 (diff) | |
| download | dots-backup-3aaaf1753d8aa444fda44064ff2c655c5788cb25.tar.gz dots-backup-3aaaf1753d8aa444fda44064ff2c655c5788cb25.zip | |
refactor: clearer arithmetic guard and output loop var in do_suggest
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'dot-backup.sh')
| -rwxr-xr-x | dot-backup.sh | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/dot-backup.sh b/dot-backup.sh index 21388f0..7c77531 100755 --- a/dot-backup.sh +++ b/dot-backup.sh @@ -265,7 +265,7 @@ do_suggest() { fi local -a candidates=() - local path emit base mtime + local path emit base mtime item # Source 1: ~/.config/* (children of .config) for path in "${HOME}/.config/"*; do @@ -275,7 +275,7 @@ do_suggest() { _suggest_ignored "$base" && continue _suggest_covered "$emit" && continue mtime="$(stat -c %Y "$path" 2>/dev/null || echo 0)" - (( mtime > last_epoch )) && candidates+=("$emit") + if (( mtime > last_epoch )); then candidates+=("$emit"); fi done # Source 2 + 3: ~/.* (hidden dirs and files at home top level) @@ -287,7 +287,7 @@ do_suggest() { _suggest_ignored "$base" && continue _suggest_covered "$emit" && continue mtime="$(stat -c %Y "$path" 2>/dev/null || echo 0)" - (( mtime > last_epoch )) && candidates+=("$emit") + if (( mtime > last_epoch )); then candidates+=("$emit"); fi done if [[ ${#candidates[@]} -eq 0 ]]; then @@ -300,13 +300,13 @@ do_suggest() { while IFS= read -r line; do sorted+=("$line"); done < <(printf '%s\n' "${candidates[@]}" | sort -u) echo -e "${GREEN}New since last backup (${last_human}):${NC}" - for emit in "${sorted[@]}"; do - echo -e " ${BLUE}${emit}${NC}" + for item in "${sorted[@]}"; do + echo -e " ${BLUE}${item}${NC}" done echo echo "Paste into files.list:" - for emit in "${sorted[@]}"; do - echo "$emit" + for item in "${sorted[@]}"; do + echo "$item" done } |
