Better handle filenames with * and ? in them.

This commit is contained in:
tlimoncelli@stackexchange.com
2014-10-14 14:43:03 +00:00
parent e12de7dfe3
commit d1a9dbcd2e
2 changed files with 8 additions and 1 deletions

View File

@@ -51,7 +51,7 @@ fi
# VCS-independent way. # VCS-independent way.
IGNOREFILE=".${VCS_TYPE}ignore" IGNOREFILE=".${VCS_TYPE}ignore"
if [[ $VCS_TYPE = 'git' ]]; then if [[ $VCS_TYPE = 'git' ]]; then
ignored_file="$(echo "$unencrypted_file" | sed 's/^\([!#]\)/\\\1/')" ignored_file="$(echo "$unencrypted_file" | sed 's/\([\*\?]\)/\\\1/g' | sed 's/^\([!#]\)/\\\1/')"
if ! grep -Fsx >/dev/null "$ignored_file" "$IGNOREFILE"; then if ! grep -Fsx >/dev/null "$ignored_file" "$IGNOREFILE"; then
echo "$ignored_file" >>"$IGNOREFILE" echo "$ignored_file" >>"$IGNOREFILE"
COMMIT_FILES="$COMMIT_FILES $IGNOREFILE" COMMIT_FILES="$COMMIT_FILES $IGNOREFILE"

View File

@@ -298,6 +298,13 @@ assert_file_missing '#andpounds.txt'
assert_file_exists '#andpounds.txt'.gpg assert_file_exists '#andpounds.txt'.gpg
assert_line_exists '\#andpounds.txt' .gitignore assert_line_exists '\#andpounds.txt' .gitignore
PHASE 'Bob enrolls stars*bars?.txt'
echo A very commented file >'stars*bars?.txt'
blackbox_register_new_file 'stars*bars?.txt'
assert_file_missing 'stars*bars?.txt'
assert_file_exists 'stars*bars?.txt'.gpg
assert_line_exists 'stars\*bars\?.txt' .gitignore
# TODO(tlim): Add test to make sure that now alice can NOT decrypt. # TODO(tlim): Add test to make sure that now alice can NOT decrypt.
# #