URL:
  <http://savannah.gnu.org/bugs/?31774>

                 Summary: Exit code 0 when path is empty
                 Project: findutils
            Submitted by: l0b0
            Submitted on: Fri 26 Nov 2010 01:57:52 PM CET
                Category: find
                Severity: 3 - Normal
              Item Group: Wrong result
                  Status: None
                 Privacy: Public
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 4.4.2
           Fixed Release: None

    _______________________________________________________

Details:

$ find ''; echo $?
find: cannot search `': No such file or directory
0

$ find '/does/not/exist'; echo $?
find: `/does/not/exist': No such file or directory
1

The actual error is slightly different (the first command couldn't possibly
succeed in any environment), but it still seems inconsistent. The first result
makes it more difficult (and less intuitive) to test code which uses a
variable for the path.

Here's some simplified testing code:

source="$(some command)"
find "$source" ... -print0 | while read -rd $'\0' path
    touch "$path"
done
if [ "0 0" != "${PIPESTATUS[*]}" ]
then
    fail 'Something failed in the loop'
    return
fi

This does not catch the situation where $source is empty. To detect that, I'd
have to tee stderr of find to a separate file and grep for something that
doesn't look like a path.




    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?31774>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/


Reply via email to