-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better, configurable name munging (#41)
A new flag `--munge [rename|filter]` controls how a name munging will work. Name munging only applies to fields named '.', '..', containing a NUL byte, or containing a forward slash '/'. The `rename` option (the default) will change '.' to '_.' and '..' to '_..'; each NUL byte turns into '_NUL_' and each slash turns into '_SLASH_'. This greatly simplified policy means that spaces and other special characters should work just fine in field names now.
- Loading branch information
Showing
12 changed files
with
255 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/sh | ||
|
||
fail() { | ||
echo FAILED: $1 | ||
if [ "$MNT" ] | ||
then | ||
umount "$MNT" | ||
rmdir "$MNT" | ||
rm "$OUT" "$EXP" | ||
fi | ||
exit 1 | ||
} | ||
|
||
MNT=$(mktemp -d) | ||
OUT=$(mktemp) | ||
EXP=$(mktemp) | ||
|
||
printf -- "---\nfield one: 1\nfield two: 2\nfield three: 3" >"$EXP" | ||
|
||
ffs -m "$MNT" --target yaml -o "$OUT" --munge filter ../yaml/spaces.yaml & | ||
PID=$! | ||
sleep 2 | ||
case $(ls "$MNT") in | ||
(field\ one*field\ two) ;; | ||
(*) fail ls;; | ||
esac | ||
[ "$(cat $MNT/field\ one)" -eq 1 ] || fail one | ||
[ "$(cat $MNT/field\ two)" -eq 2 ] || fail two | ||
echo 3 >"$MNT"/field\ three | ||
|
||
umount "$MNT" || fail unmount | ||
sleep 1 | ||
kill -0 $PID >/dev/null 2>&1 && fail process | ||
|
||
grep "field three: 3" $OUT >/dev/null 2>&1 || fail three | ||
|
||
sort $OUT >$OUT.yaml | ||
sort $EXP >$EXP.yaml | ||
diff $OUT.yaml $EXP.yaml || fail diff | ||
|
||
rmdir "$MNT" || fail mount | ||
rm "$OUT" "$EXP" |
Oops, something went wrong.