summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debian/changelog6
-rwxr-xr-xpre-commit.d/30store-metadata12
2 files changed, 15 insertions, 3 deletions
diff --git a/debian/changelog b/debian/changelog
index 7773187..4614159 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+etckeeper (0.58) UNRELEASED; urgency=low
+
+ * Bugfix for filenames containing single quotes.
+
+ -- Joey Hess <joeyh@debian.org> Fri, 25 Nov 2011 12:00:55 -0400
+
etckeeper (0.57) unstable; urgency=low
* Use find -path instead of less portable find -wholename.
diff --git a/pre-commit.d/30store-metadata b/pre-commit.d/30store-metadata
index 2e35e6c..aeec374 100755
--- a/pre-commit.d/30store-metadata
+++ b/pre-commit.d/30store-metadata
@@ -32,10 +32,16 @@ filter_ignore() {
statf() {
while read statfile; do
- echo "$(stat --format="$1" "$statfile") '$statfile'"
+ printf "$(stat --format="$1" "$statfile") "
+ echo "$statfile" | shellquote
done
}
+shellquote() {
+ # Single quotes text, escaping existing single quotes.
+ sed -e "s/'/'\"'\"'/" -e "s/^/'/" -e "s/$/'/"
+}
+
generate_metadata() {
# This function generates the script commands to fix any files
# that aren't owner=root, group=root, or mode=0644 or 0755.
@@ -60,7 +66,7 @@ generate_metadata() {
# These version control systems do not track directories,
# so empty directories must be stored specially.
find $NOVCS -type d -empty -print |
- sort | sed -e "s/^/mkdir -p '/" -e "s/\$/'/"
+ sort | shellquote | sed -e "s/^/mkdir -p /"
fi
if [ "$VCS" = darcs ]; then
@@ -68,7 +74,7 @@ generate_metadata() {
# so they must be stored specially.
find $NOVCS -type l -print | sort | filter_ignore | while read link; do
dest=$( readlink "$link" )
- printf "ln -sf '%s' '%s'\n" "$dest" "$link"
+ printf "ln -sf '%s' '%s'\n" "$(echo "$dest" | shellquote)" "$(echo "$link" | shellquote)"
done
fi