1 |
Steve Long wrote: |
2 |
|
3 |
> Thomas Sachau wrote: [...] |
4 |
> |
5 |
> > [[ -n ${DOCS} ]] && dodoc ${DOCS} |
6 |
[...] |
7 |
> |
8 |
> It might be wise to use an array for DOCS there |
9 |
|
10 |
Since I have now seen suggestions for using arrays unnecessarily |
11 |
at least twice (see also |
12 |
[RFC] Ability to pass arguments to src_configure/src_compile |
13 |
but I am only speaking about the usage of _arrays_ here), |
14 |
let me remark that the more clever way to this is |
15 |
|
16 |
[ -n "${DOCS}" ] && eval "dodoc ${DOCS}" |
17 |
|
18 |
This way, people can simply quote as they like: |
19 |
|
20 |
DOCS="'filename with spaces' filename_without_space doc/*" |
21 |
|
22 |
or also |
23 |
|
24 |
DOCS="just_one_filename_without_special_characters" |
25 |
|
26 |
or also - when Push from /usr/bin/functions-eix.sh is used |
27 |
(which might be implemented simpler without using other functions): |
28 |
|
29 |
Push DOCS 'filename with spaces' filename_without_space "${S}"/doc/* |
30 |
|
31 |
|
32 |
Not only has this the advantage that it is POSIX (and thus does not |
33 |
force ebuilds to use the particular shell "bash" - a policy which perhaps |
34 |
some day might be changed: It is dangerous to depend on a particular |
35 |
implementation), the array-less solution is also much simpler to |
36 |
implement, easy to understand from the source, and clearer in usage. |
37 |
Case distinctions like |
38 |
|
39 |
> isArr() [[ $(declare -p "$1" 2>/dev/null) = 'declare -a'* ]] |
40 |
> if isArr DOCS; then |
41 |
> ((${#DOCS[@]})) && dodoc "${DOCS[@]}" |
42 |
> else [[ $DOCS ]] && dodoc $DOCS |
43 |
> fi |
44 |
|
45 |
are just awful. |