1
1
mirror of https://github.com/mgree/ffs.git synced 2024-07-14 14:50:23 +03:00
ffs/tests/bad_root_stdin.sh
Michael Greenberg 4aff907523
Better mount control (issue #12; pr #24)
Mountpoints are typically inferred/generated from filenames with a -m/--mount flag for when reading from STDIN or to manually specify a mountpoint.
2021-06-24 07:06:38 -07:00

28 lines
497 B
Bash
Executable File

#!/bin/sh
fail() {
echo FAILED: $1
if [ "$MNT" ]
then
umount "$MNT"
rmdir "$MNT"
rm "$MSG" "$OUT"
fi
exit 1
}
MNT=$(mktemp -d)
OUT=$(mktemp)
MSG=$(mktemp)
echo \"just a string\" | ffs -m "$MNT" >"$OUT" 2>"$MSG" &
PID=$!
sleep 1
kill -0 $PID >/dev/null 2>&1 && fail process
cat "$MSG" | grep -i -e "must be a directory" >/dev/null 2>&1 || fail error
[ -f "$OUT" ] && ! [ -s "$OUT" ] || fail output
sleep 1
rmdir "$MNT" || fail mount
rm "$MSG" "$OUT"