On Mon, 18 Oct 2010 14:06:26 -0400 Mike Frysinger <[email protected]> wrote:
> On Monday, October 18, 2010 03:08:15 Michał Górny wrote:
> > On Wed, 13 Oct 2010 17:46:43 -0400 Mike Frysinger wrote:
> > > On Wednesday, October 13, 2010 15:57:17 Amadeusz Żołnowski wrote:
> > > > And why putting different tasks into one function?
> > >
> > > for the same reason we dont have separate test binaries:
> > > test_exist, test_file, test_dir, etc...
> > >
> > > it makes more sense in my mind to combine the functionality.
> >
> > And we finally reach the point where there is no reason to implement
> > a new function when it's supposed to be basically longer and more
> > unclear to use than:
> >
> > [[ -f a || -f b || -f c ]]
>
> except that we're using globs, so our example isnt applicable.
> [[ -f */a ]]
Ok. So, let's sum up what your function does with wildcards:
1) when passed a single wildcard, the OR and AND variants basically do
the same (unless one of the matched files disappears during the
check), so their co-existence is useless in that case.
2) When passed multiple wildcards (or a wildcard and filenames), these
variants indeed are both useful but the AND variant does unnecessary
amount of checking (checking each filename matched by each wildcard)
and is fragile to a single matched file disappearing during the runtime.
So, it's basically safer to use:
if path_exists -o a/* && path_exists -o b/*; then
...
fi
--
Best regards,
Michał Górny
signature.asc
Description: PGP signature
