feat: improve scripts and write tests

This commit is contained in:
alexm committed 2026-10-11 07:22:13 -04:00
1 parent bc3091647e
commit cf4bd07a8e
32 files changed
+3817 -723

No files matched your search

+16
View File
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
# Fake findmnt driven by $FAKE_MOUNTS: lines of "SOURCE TARGET" (raw-escaped).
[[ -z "${FAKE_FINDMNT_FAIL:-}" ]] || { echo "findmnt: simulated failure" >&2; exit 1; }
touch "${FAKE_MOUNTS:?}"
if [[ "$*" == *"--target"* ]]; then
path="${@: -1}"; best="" src=""
while read -r s t; do
t="$(printf '%b' "$t")"
if [[ "$path" == "$t" || "$path" == "$t"/* || "$t" == / ]]; then
((${#t} >= ${#best})) && { best="$t"; src="$s"; }
fi
done < "$FAKE_MOUNTS"
[[ -n "$src" ]] && { echo "$src"; exit 0; }
exit 1
fi
cat "$FAKE_MOUNTS"