[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] vc-list-files: restore lost functionality with subdir argume
From: |
Jim Meyering |
Subject: |
Re: [PATCH] vc-list-files: restore lost functionality with subdir argument |
Date: |
Sat, 25 Apr 2009 15:34:52 +0200 |
Eric Blake wrote:
> According to Jim Meyering on 4/25/2009 2:27 AM:
>> The latest vc-list-files change made coreutils' "make sc_root_tests"
>> fail, due to lack of the tests/ prefix on the listed file names.
>> This fixes it, but adds the implicit constraint that the dirname
>> argument to vc-list-files must not contain "!".
>
> Good catch.
>
>> + eval exec git ls-tree -r 'HEAD:"$dir"' \
>> + \| sed -n '"s!^100[^ ]*.!'"$dir"'!p"' $postprocess
>
> Is that the right quoting? Remember, this line is going through an eval,
> and we don't want a $dir containing whitespace to show up as separate
> arguments to sed. I think it should be:
>
> eval exec git ls-tree -r 'HEAD:"$dir"' \
> \| sed -n '"s!^100[^ ]*.!$dir!p"' $postprocess
Thanks!
Your proposed change is required, but not because of
whitespace, which does not cause trouble, but rather
because of something worse: shell expansion:
Before, it was very wrong ;-)
d='a-$(printf "\x62\x6f\x6f\x6d")'
$ vc-list-files "$d"
a-boom/a
a-boom/b
Patched as you've just done, we still have undesirable sed-expansion:
$ vc-list-files "$d"
a-$(printf "boom")/a
a-$(printf "boom")/b
With the following additional change, I get what I want:
$ vc-list-files "$d"
a-$(printf "\x62\x6f\x6f\x6d")/a
a-$(printf "\x62\x6f\x6f\x6d")/b
tested like this:
d='a-$(printf "\x62\x6f\x6f\x6d")'
git init
mkdir "$d" && (cd "$d" && touch a b && git add a b && git ci -m. -a)
/gnulib/build-aux/vc-list-files "$d"
I've also reverted to using "/" as the sed delimiter,
thus allowing "!" once again.
>From 0bb361f27252ad8308f8e208af76536821ce29ce Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Sat, 25 Apr 2009 15:32:33 +0200
Subject: [PATCH] vc-list-files: fix another quoting bug
* build-aux/vc-list-files: Avoid sed backslash expansion
of pathological directory names.
---
ChangeLog | 6 ++++++
build-aux/vc-list-files | 6 ++++--
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 689b372..27de447 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-04-25 Jim Meyering <address@hidden>
+
+ vc-list-files: fix another quoting bug
+ * build-aux/vc-list-files: Avoid sed backslash expansion
+ of pathological directory names.
+
2009-04-25 Eric Blake <address@hidden>
vc-list-files: fix shell quoting error
diff --git a/build-aux/vc-list-files b/build-aux/vc-list-files
index 08dc8ab..9376e3d 100755
--- a/build-aux/vc-list-files
+++ b/build-aux/vc-list-files
@@ -72,13 +72,15 @@ esac
test "x$dir" = x && dir=.
if test -d .git; then
- test "x$dir" = x. && dir= || dir="$dir/"
+ test "x$dir" = x. \
+ && dir= sed_esc= \
+ || dir="$dir/" sed_esc=`echo "$dir"|sed 's,\([\\/]\),\\\\\1,g'`
# Ignore git symlinks - either they point into the tree, in which case
# we don't need to visit the target twice, or they point somewhere
# else (often into a submodule), in which case the content does not
# belong to this package.
eval exec git ls-tree -r 'HEAD:"$dir"' \
- \| sed -n '"s!^100[^ ]*.!$dir!p"' $postprocess
+ \| sed -n '"s/^100[^ ]*./$sed_esc/p"' $postprocess
elif test -d .hg; then
eval exec hg locate '"$dir/*"' $postprocess
elif test -d .bzr; then
--
1.6.3.rc1.223.g2f326