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