find . -delete gives an error message for the . directory entry
Matthias Andree
mandree at FreeBSD.org
Sat Sep 26 14:02:06 UTC 2015
Am 25.09.2015 um 17:01 schrieb Ari Sundholm:
> Hello!
>
> Busybox (git HEAD) seems to give an error when doing a "find . -delete"
> within a directory:
>
> ------------------>8-------------------------------------------------
> ~/busybox/foobarbaz$ ls
> ~/busybox/foobarbaz$ find
> .
> ~/busybox/foobarbaz$ find . -delete
> ~/busybox/foobarbaz$ echo $?
> 0
> ~/busybox/foobarbaz$ ../busybox find . -delete
> find: .: Invalid argument
> ~/busybox/foobarbaz$ echo $?
> 0
> ------------------>8-------------------------------------------------
>
> This error is not given by the findutils version, as shown above.
> Strangely enough, the error is not reflected in the return value. This
> happens also when the directory is non-empty.
Yeah, that's quite normal, the utility is exposing the mandatory error
of the underlying OS kernel. - UNIX systems are required to return
EINVAL if you try to rmdir .
Try "rmdir ." directly:
Ubuntu Linux:
> $ LC_ALL=C rmdir .
> rmdir: failed to remove '.': Invalid argument
FreeBSD 10.2:
> $ env LC_ALL=C rmdir .
> rmdir: .: Invalid argument
SUSv4 does not specify -delete for the find utility.
Bottom line: findutils suppress the pilot error from view, busybox does
not. Either is permissible, depending on implementation-specific
behaviour of the nonstandard "-delete" option.
More information about the busybox
mailing list