mirror of
https://github.com/BaaRai/ARTEX.git
synced 2026-11-13 11:40:53 +08:00
fix(backup): reject --keep 0 so the new dump is never pruned
With --keep 0, prune ran tail -n +1 over the newest-first listing and deleted every dump, including the one written seconds earlier, then reported success. The check also rejects leading zeros, which the $((KEEP + 1)) arithmetic would parse as octal (08 and 09 abort the script after the dump).
This commit is contained in:
+3
-1
@@ -31,7 +31,9 @@ while [ $# -gt 0 ]; do
|
||||
*) echo "unknown option: $1" >&2; usage >&2; exit 2 ;;
|
||||
esac
|
||||
done
|
||||
case "$KEEP" in (*[!0-9]*|'') echo "--keep must be a positive integer" >&2; exit 2 ;; esac
|
||||
# 0* rejects 0, which would make prune delete the dump this run just wrote, and
|
||||
# leading zeros, which $((KEEP + 1)) would read as octal.
|
||||
case "$KEEP" in (*[!0-9]*|''|0*) echo "--keep must be a positive integer" >&2; exit 2 ;; esac
|
||||
|
||||
# Compose reads .env for credentials; source it for the dump command too.
|
||||
if [ -f .env ]; then
|
||||
|
||||
Reference in New Issue
Block a user