Re: [dev] [sbase] [PATCH v2] rm: Fix exit status with -f for nonexistent paths

From: FRIGN <dev_AT_frign.de>
Date: Sun, 1 Mar 2015 23:23:28 +0100

On Sun, 1 Mar 2015 21:59:02 +0000
Michael Forney <mforney_AT_mforney.org> wrote:

Hey Michael,

Thanks for paying so close attention! You are right
about the return value!

> if (remove(path) < 0) {
> + if (!rm_fflag || errno != ENOENT)
> + rm_status = 1;
> if (!rm_fflag)
> weprintf("remove %s:", path);
> - rm_status = 1;
> }

I'd do it like this instead, makes it clearer that we're
dealing with one special case:

        if (remove(path) < 0) {
                if (!rm_fflag)
                        weprintf("remove %s:", path);
                rm_status = !(rm_fflag && errno == ENOENT);
        }

What do you think?

Cheers

FRIGN

--
FRIGN <dev_AT_frign.de>
Received on Sun Mar 01 2015 - 23:23:28 CET

This archive was generated by hypermail 2.3.0 : Sun Mar 01 2015 - 23:36:03 CET