Web lists-archives.com

Re: Do test-path_is_{file,dir,exists} make sense anymore with -x?




On Tue, Feb 26, 2019 at 11:10 PM Ævar Arnfjörð Bjarmason
<avarab@xxxxxxxxx> wrote:
>
>
> On Tue, Feb 26 2019, Duy Nguyen wrote:
>
> > On Tue, Feb 26, 2019 at 8:42 PM Rohit Ashiwal via GitGitGadget
> > <gitgitgadget@xxxxxxxxx> wrote:
> >>
> >> From: Rohit Ashiwal <rohit.ashiwal265@xxxxxxxxx>
> >>
> >> t3600-rm.sh: Previously we were using `test -(d|f)`
> >> to verify the presencee of a directory/file, but we
> >> already have helper functions, viz, test_path_is_dir
> >> and test_path_is_file with same functionality. This
> >
> > It's not just the same (no point replacing then). It's better. When
> > test_path_is_xxx fails, you get an error message. If "test -xxx"
> > fails, you get a failed test with no clue what caused it.
>
> I swear I'm not just on a mission to ruin everyone's GSOC projects. This
> patch definitely looks good, and given that we have this / document it
> makes sense.
>
> However. I wonder in general if we've re-visited the utility of these
> wrappers and maybe other similar wrappers after -x was added.

It's personal, but every time I have to use -x I curse a little. It's
just often too much to read.

Besides what people have already said, there's another good potential
for test_path_is_file and friends. You can make it support multiple
arguments, so that you can check if many paths are file with just one
line. Used properly, this could reduce repetition and shorten some
test cases a bit without sacrificing readability.
-- 
Duy