From 1df79c3c1d65c05472fdc08564efefc37c221d25 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Wed, 1 Feb 2012 21:01:26 +0100 Subject: grep: Accept file names with spaces This is a continuation of Yasushi SHOJI's initial work of fixing support for file names with spaces. This time I fixed support in the grep command. This is particularly important because the grep command operates on all files in the work tree, even if they aren't touched by any patch, so the chances that one of them has a space in its name is greater. As before, no guarantee is made that all options are covered, but this should be a good starting point. --- quilt.changes | 5 +++++ quilt/grep.in | 4 ++-- test/space-in-filenames.test | 7 +++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/quilt.changes b/quilt.changes index f160fd0..11dccd6 100644 --- a/quilt.changes +++ b/quilt.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Wed Feb 1 21:00:45 CET 2012 - jdelvare@suse.de + +- grep: Accept file names with spaces. + ------------------------------------------------------------------- Wed Feb 1 20:15:01 CET 2012 - jdelvare@suse.de diff --git a/quilt/grep.in b/quilt/grep.in index 270ba9c..0c32fcf 100644 --- a/quilt/grep.in +++ b/quilt/grep.in @@ -117,8 +117,8 @@ fi find "${myargs[@]:-.}" \( \ -path "./$QUILT_PATCHES/*" -o \ -path "./$QUILT_PC/*" \) -prune -o \ - -type f -print \ -| xargs grep $opt_H "${args[@]}" \ + -type f -print0 \ +| xargs -0 grep $opt_H "${args[@]}" \ | if [ ${#myargs[@]} -eq 0 ]; then sed -e 's,^./,,' else diff --git a/test/space-in-filenames.test b/test/space-in-filenames.test index eb0d035..fa0ddf8 100644 --- a/test/space-in-filenames.test +++ b/test/space-in-filenames.test @@ -77,6 +77,13 @@ $ cat patches/test.diff > -foo > +bar +$ quilt grep bar +> foo bar:bar +$ quilt grep new +> a: b [c]:new line +$ quilt grep " " +> a: b [c]:new line + $quilt remove "a: b [c]" > File a: b [c] removed from patch patches/test.diff -- cgit