Subject: Re: [PATCH 1/1] t1403: prefer test_path_exists helper function

From: Junio C Hamano <[email-masked]>
Date: Tue, 04 Mar 2025 09:26:58 -0800

Mahendra Dani <[email-masked]> writes:

> On Tue, Mar 4, 2025 at 5:35 PM Junio C Hamano <[email-masked]> wrote:
>>
>> Mahendra Dani <[email-masked]> writes:
>>
>> >> >       remove_object() {
>> >> >               file=$(sha1_file "$*") &&
>> >> > -             test -e "$file" &&
>> >> > +             test_path_exists "$file" &&
>> >> >               rm -f "$file"
>> >> >       } &&
>>
>> You may want to think about why there is "-f" there.  If we remove
>> it, do we still need to have any check there?
>
> Here, the "-f" flag in `rm -f "$file"` does not produce an error message even
> if the file does not exist [1], thus the `test -e "$file"` check was redundant,
> as pointed out by Patrick in [2].

So what happens if you dropped "-f" as I hinted?  We'll notice the
lack of file and the command exits with non-zero status.  So "test -e"
was not necessary in the first place, was it?