On Sat, Sep 20, 2008 at 11:18 PM, Vaeth <[EMAIL PROTECTED]> wrote: > Steve Long wrote: > >> Thomas Sachau wrote: [...] >> >> > [[ -n ${DOCS} ]] && dodoc ${DOCS} > [...] >> >> It might be wise to use an array for DOCS there > > Since I have now seen suggestions for using arrays unnecessarily > at least twice (see also > [RFC] Ability to pass arguments to src_configure/src_compile > but I am only speaking about the usage of _arrays_ here), > let me remark that the more clever way to this is > > [ -n "${DOCS}" ] && eval "dodoc ${DOCS}" > > This way, people can simply quote as they like: > > DOCS="'filename with spaces' filename_without_space doc/*" > > or also > > DOCS="just_one_filename_without_special_characters" > > or also - when Push from /usr/bin/functions-eix.sh is used > (which might be implemented simpler without using other functions): > > Push DOCS 'filename with spaces' filename_without_space "${S}"/doc/* > > > Not only has this the advantage that it is POSIX (and thus does not > force ebuilds to use the particular shell "bash" - a policy which perhaps > some day might be changed: It is dangerous to depend on a particular > implementation), the array-less solution is also much simpler to > implement, easy to understand from the source, and clearer in usage. > Case distinctions like
gentoo-x86 uses bash; the ebuilds, the eclasses, they all rely on it. I'm pretty sure most package managers rely on bash as well, but I have not looked at the code outside of portage to verify. I really dislike ideas where the compelling argument is 'in the future we may make a specific decision and that makes that one choice easier.' If switching to POSIX shell was on the road map for Gentoo or Gentoo-x86 or any of the package managers; I would maybe buy your argument. But as far as I am aware it is not; so planning for future decisions that currently are undecided is folly in my mind. It is much more pragmatic to use bash now (since we already use it) and utilize its features. If you have a compelling argument for switching the entire tree to POSIX then give it; however I'm pretty sure it is a difficult argument to make (Uberlord tried to make it in the past and did not succeed). Otherwise lets just roll with the bash implementation. -Alec > >> isArr() [[ $(declare -p "$1" 2>/dev/null) = 'declare -a'* ]] >> if isArr DOCS; then >> (([EMAIL PROTECTED])) && dodoc "[EMAIL PROTECTED]" >> else [[ $DOCS ]] && dodoc $DOCS >> fi > > are just awful. > >