Public bug reported:

Binary package hint: coreutils

basename does not return the correct basename when executed using
command substitution from find (-exec) or xargs (dirname does).

works using find -exec directly
$ find . -type f -iname '*.jpg' -exec basename {} \;
Patio before.JPG
Patio1-1.JPG
Patio1-2.JPG
Patio1-3.JPG

does not work using find -exec using command substitution
$ find . -type f -iname '*.jpg' -exec printf "$( basename {} ) \n" \;
./Patio before.JPG 
./Patio1-1.JPG 
./Patio1-2.JPG 
./Patio1-3.JPG 

dirname works using find -exec using command substitution
$ find . -type f -iname '*.jpg' -exec printf "$( dirname {} ) \n" \;
. 
. 
. 
. 

works direct from xargs
printf "./Patio1-1.JPG\n" | xargs -0 -I{} basename {}
Patio1-1.JPG

does not work from xargs with command substitution (again dirname does)
printf "./Patio1-1.JPG\n" | xargs -0 -I{} printf " fullname:{} basename:$( 
basename "{}" ) dirname:$( dirname "{}" )\n"
 fullname:./Patio1-1.JPG
 basename:./Patio1-1.JPG
 dirname:.


System information:
9.10 karmic
ii  findutils                                  4.4.2-1                          
          utilities for finding files--find, xargs
ii  coreutils                                  7.4-2ubuntu1                     
          The GNU core utilities
uname -a
Linux aegir 2.6.31-19-generic #56-Ubuntu SMP Thu Jan 28 02:39:34 UTC 2010 
x86_64 GNU/Linux

$ which basename
/usr/bin/basename

Let me know if you need anything else to help with this.   Thanks,

** Affects: coreutils (Ubuntu)
     Importance: Undecided
         Status: New

-- 
basename problems with xargs/find and command substitution
https://bugs.launchpad.net/bugs/523453
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to