diff options
author | Bernhard Voelker <mail@bernhard-voelker.de> | 2017-02-20 18:53:48 +0100 |
---|---|---|
committer | Bernhard Voelker <mail@bernhard-voelker.de> | 2017-02-20 18:54:08 +0100 |
commit | 2a6129bfccec9f23a50f037e187f85c4d000bc87 (patch) | |
tree | 96ba9cd3ef4ca61fdfe19376e7419661ca32cd50 /find/testsuite/find.gnu/printf-h.exp | |
parent | 9d849f77d55882e4049aec5676024b94097f33f7 (diff) | |
download | findutils-2a6129bfccec9f23a50f037e187f85c4d000bc87.tar.gz |
find: fix -printf '%h' for arguments with one or more trailing slashes
Previously, find would output the pathname name for the '%h' format
when that was passed with a trailing slash:
$ mkdir foo
$ find foo/ -printf '%h/%f\n'
foo/foo/
* find/print.c (do_fprintf -> 'h'): Strip trailing slashes, i.e. any
number of directory separators, unless this is the root "/" directory.
* find/testsuite/find.gnu/printf-h.exp: Enhance test with various
combinations of "/", "./", "foo/", "./foo", "./foolink/", etc.
* find/testsuite/find.gnu/printf-h.xo: Add the expected output for the
above new test cases.
* NEWS: Mention the fix.
Bug introduced in commit FINDUTILS_4_2_18-1-6-g0fd15a4.
Reported by Tavian Barnes <tavianator@gmail.com> in
https://savannah.gnu.org/bugs/?50259
Diffstat (limited to 'find/testsuite/find.gnu/printf-h.exp')
-rw-r--r-- | find/testsuite/find.gnu/printf-h.exp | 94 |
1 files changed, 90 insertions, 4 deletions
diff --git a/find/testsuite/find.gnu/printf-h.exp b/find/testsuite/find.gnu/printf-h.exp index fb0187cc..094a37b5 100644 --- a/find/testsuite/find.gnu/printf-h.exp +++ b/find/testsuite/find.gnu/printf-h.exp @@ -1,5 +1,91 @@ # Test case for Savannah bug ID #12085. -exec rm -rf tmp -exec touch tmp -find_start p {tmp -printf "RESULT: %h %f\n" } -exec rm -rf tmp +exec rm -rf foo +exec mkdir foo foo/bar +exec ln -s foo foolink +# +# Create the combinations with: +# $ printf '%s \\\n' {,./,.//}{/,.,foo,foolink,foo/bar}{,/,//,/.,//.} | sort -u +# +# Manual check against installed version: +# $ for opt in '' -H -L -P ; do +# printf "\n=== Differences for option: '%s' ===\n" "$opt" +# diff -u0 \ +# <( /usr/bin/find $opt {,./,.//}{/,.,foo,foolink,foo/bar}{,/,//,/.,//.} \ +# -maxdepth 1 -printf "%h/%f,%%p=%p,%%h='%h',%%f='%f'\n" ) \ +# <( ./find $opt {,./,.//}{/,.,foo,foolink,foo/bar}{,/,//,/.,//.} \ +# -maxdepth 1 -printf "%h/%f,%%p=%p,%%h='%h',%%f='%f'\n" ) +# done | column -t -s, + +find_start p {\ +/ \ +// \ +/// \ +///. \ +//. \ +. \ +./ \ +.// \ +./// \ +.//// \ +.///// \ +./////. \ +.////. \ +.///. \ +.//. \ +.//./ \ +.//.// \ +.//.//. \ +.//./. \ +./. \ +././ \ +./.// \ +././/. \ +././. \ +.//foo \ +.//foo/ \ +.//foo// \ +.//foo//. \ +.//foo/. \ +./foo \ +./foo/ \ +./foo// \ +./foo//. \ +./foo/. \ +foo \ +foo/ \ +foo// \ +foo//. \ +foo/. \ +.//foo/bar \ +.//foo/bar/ \ +.//foo/bar// \ +.//foo/bar//. \ +.//foo/bar/. \ +./foo/bar \ +./foo/bar/ \ +./foo/bar// \ +./foo/bar//. \ +./foo/bar/. \ +foo/bar \ +foo/bar/ \ +foo/bar// \ +foo/bar//. \ +foo/bar/. \ +.//foolink \ +.//foolink/ \ +.//foolink// \ +.//foolink//. \ +.//foolink/. \ +./foolink \ +./foolink/ \ +./foolink// \ +./foolink//. \ +./foolink/. \ +foolink \ +foolink/ \ +foolink// \ +foolink//. \ +foolink/. \ +-maxdepth 0 -printf "%p,%h,%f\n" } + +exec rm -rf foo foolink |