feat: improve scripts and write tests
This commit is contained in:
32 files changed
+3817
-723
No files matched your search
Executable
+16
@@ -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"
|
||||
Reference in new issue
Block a user