[PATCH] find: implement -empty

Denys Vlasenko vda.linux at googlemail.com
Thu Sep 12 10:01:38 UTC 2019


On Tue, Sep 10, 2019 at 10:06 PM Aaro Koskinen <aaro.koskinen at iki.fi> wrote:
> Implement -empty.
>
> Signed-off-by: Aaro Koskinen <aaro.koskinen at iki.fi>
> ---
>  findutils/find.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 45 insertions(+)
>
> diff --git a/findutils/find.c b/findutils/find.c
> index d6679bd08..3e4ae3266 100644
> --- a/findutils/find.c
> +++ b/findutils/find.c
> @@ -203,6 +203,14 @@
>  //config:      WARNING: This option can do much harm if used wrong. Busybox will not
>  //config:      try to protect the user from doing stupid things. Use with care.
>  //config:
> +//config:config FEATURE_FIND_EMPTY
> +//config:      bool "Enable -empty: match empty files or directories"
> +//config:      default y
> +//config:      depends on FIND
> +//config:      help
> +//config:        Support the 'find -empty' option to find empty regular files
> +//config:        or directories.
> +//config:
>  //config:config FEATURE_FIND_PATH
>  //config:      bool "Enable -path: match pathname with shell pattern"
>  //config:      default y
> @@ -333,6 +341,9 @@
>  //usage:       IF_FEATURE_FIND_DELETE(
>  //usage:     "\n       -delete         Delete current file/directory. Turns on -depth option"
>  //usage:       )
> +//usage:       IF_FEATURE_FIND_EMPTY(
> +//usage:     "\n       -empty          Match empty file/directory."
> +//usage:       )
>  //usage:       IF_FEATURE_FIND_QUIT(
>  //usage:     "\n       -quit           Exit"
>  //usage:       )

"""
If none of the following actions is specified, -print is assumed
        -print          Print file name
        -print0         Print file name, NUL terminated
        -exec CMD ARG ; Run CMD with all instances of {} replaced by
                        file name. Fails if CMD exits with nonzero
        -exec CMD ARG + Run CMD with {} replaced by list of file names
        -delete         Delete current file/directory. Turns on -depth option
        -empty          Match empty file/directory.
        -quit           Exit
"""

The above is wrong: -empty does not "turn off" implicit -print.
IOW: -empty help text should be above this block.


More information about the busybox mailing list