fix/disk-usage-quoting #11

Merged
ludovic.terrier merged 3 commits from fix/disk-usage-quoting into master 2026-11-12 14:05:25 +01:00
Owner
No description provided.
disk_usage.sh had no tests and a hardcoded /photos/external root, so
nothing guarded its output before the quoting fix. The root now reads
DISK_USAGE_ROOT like empty.sh does; unset keeps the production path and
an empty value aborts, so a stray empty variable cannot scan
/archives/.

The tests pin the current format, sort order, the _raw exclusion, the
empty RAW field when _raw is missing, and the abort paths. du --exclude
is GNU-only, so the output tests skip with a message on BSD du instead
of changing the production command.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The year directories came from a word-split $(find | sort), and every
du call took the path unquoted. A space split one directory into
several bogus ones, a glob character expanded to a sibling and reported
its sizes, a piece that started with a dash after word splitting
reached du as an option, and a newline broke the list.

find -print0 | sort -z feeds a while read -d '' loop, every expansion is
quoted, and du gets -- before the path. Options now come before the
path; GNU du permutes arguments, so the parse is the same, and old and
new output were compared byte for byte (stdout, stderr, exit code) on
an ordinary tree with GNU coreutils 9.12. Only the first line of du
output is read, so a newline in a path does not leak into the report.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The bare "# TODO" header said nothing about the script, and the
commented-out find example pointed at /photos/vrac/done with a pattern
that no longer matches list_directories. A one-line purpose header,
like empty.sh has, replaces both. Comments only; no behaviour change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ludovic.terrier/scripts!11
No description provided.