'local result=$(cmd)' resets $? to 0 (the local builtin's own exit), so the
following checkSuccess always saw success regardless of cmd's real exit — the
mechanism that masked the de-sudo write failures. Split declaration from
assignment ('local result; result=$(cmd)') across all 235 active-code sites
(84 files) so the command's exit reaches checkSuccess. No behaviour change
beyond $? now being accurate (no set -e in runtime code; multi-line
assignments transform safely).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: librelad <librelad@digitalangels.vip>
16 lines
933 B
Bash
Executable File
16 lines
933 B
Bash
Executable File
#!/bin/bash
|
|
|
|
gitCleanInstallBackups()
|
|
{
|
|
# Remove the unzipped backup_<ts>/ snapshot dirs we just rolled up, keeping
|
|
# the .zip files themselves. `-mindepth 1 -maxdepth 1` limits to direct
|
|
# children of $backup_install_dir; `-exec rm -rf {} +` handles dirs via
|
|
# -r. The previous `-type f ! -name '*.zip' -o -type d ! -name '*.zip'`
|
|
# mis-applied the -exec to only the second clause (-o binds looser than
|
|
# the implicit -a), so it deleted every non-.zip dir under the WHOLE tree
|
|
# while matching no files at all.
|
|
local result; result=$(runInstallOp find "$backup_install_dir" -mindepth 1 -maxdepth 1 ! -name '*.zip' -exec rm -rf {} +)
|
|
checkSuccess "Cleaning up install backup folders."
|
|
local result; result=$(cd "$backup_install_dir" && find . -maxdepth 1 -type f -name '*.zip' | xargs ls -t | tail -n +6 | xargs -r rm)
|
|
checkSuccess "Deleting old install backup and keeping the latest 5."
|
|
} |