From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([69.77.167.62] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1KhNmg-0004hg-53 for garchives@archives.gentoo.org; Sun, 21 Sep 2008 12:11:26 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 85D29E0730; Sun, 21 Sep 2008 12:11:25 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 35071E0730 for ; Sun, 21 Sep 2008 12:11:25 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 1B10865FA9 for ; Sun, 21 Sep 2008 12:11:24 +0000 (UTC) X-Virus-Scanned: amavisd-new at gentoo.org X-Spam-Score: -1.487 X-Spam-Level: X-Spam-Status: No, score=-1.487 required=5.5 tests=[AWL=0.044, BAYES_00=-2.599, RCVD_IN_DNSWL_LOW=-1, RCVD_NUMERIC_HELO=2.067, WEIRD_PORT=0.001] Received: from smtp.gentoo.org ([127.0.0.1]) by localhost (smtp.gentoo.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rPss-F48Rk5y for ; Sun, 21 Sep 2008 12:11:17 +0000 (UTC) Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTP id 68DDA65D27 for ; Sun, 21 Sep 2008 12:11:16 +0000 (UTC) Received: from list by ciao.gmane.org with local (Exim 4.43) id 1KhNmT-0006vx-1C for gentoo-dev@gentoo.org; Sun, 21 Sep 2008 12:11:13 +0000 Received: from 91.85.128.198 ([91.85.128.198]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 21 Sep 2008 12:11:13 +0000 Received: from slong by 91.85.128.198 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 21 Sep 2008 12:11:13 +0000 X-Injected-Via-Gmane: http://gmane.org/ To: gentoo-dev@lists.gentoo.org From: Steve Long Subject: [gentoo-dev] Re: Re: Default src_install for EAPI-2 or following EAPI Date: Sun, 21 Sep 2008 13:03:01 +0100 Message-ID: References: Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 91.85.128.198 User-Agent: KNode/0.10.9 Sender: news X-Archives-Salt: d2d4ee3c-788b-4173-b276-f51e8a717a38 X-Archives-Hash: ea386c68492eb4a73465cd4406792abc Vaeth 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}" > eval is _not_ clever. Try: /msg greybot eval ..or check http://wooledge.org:8000/BashFAQ/048 > This way, people can simply quote as they like: > > DOCS="'filename with spaces' filename_without_space doc/*" > Yeuch. > or also > > DOCS="just_one_filename_without_special_characters" > You don't need quotes there. > 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/* > Or just do DOCS+=(foo/* someFile 'some other File') at any point. BASH arrays will cope with *any* character apart from NUL, which isn't allowed in filenames. Can you _guarantee_ the same? For instance, what if some crazy designer puts a file called: Vaeth's "Latest" Hits ..in that doc dir; what happens after the Push function has been called and, only at a later stage, the eval is run on the result of that glob expansion? > 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), I'm not getting back into that discussion, since we had the same one over a period of months already. Ebuilds require BASH; get over it. If we could move ahead with actually using BASH properly (and cleanly) it would be nice. BASH is as portable as GNU make is, and you clearly have no issue depending on that, and Python or C++. BTW, POSIX sh doesn't need ${DOCS} or ${S} either, you're just wasting characters. > the array-less solution is also much simpler to > implement, easy to understand from the source, and clearer in usage. Not to me it's not, it looks awful, to read and to type, as well as being fragile. Furthermore you're bringing eval into the script new people are going to look at to learn from (it's core functionality, fulfilling a basic task) which is dangerous from a long-term pov, imo. Leave aside having to maintain that cruft. > Case distinctions like > >> if isArr DOCS; then >> ((${#DOCS[@]})) && dodoc "${DOCS[@]}" >> else [[ $DOCS ]] && dodoc $DOCS >> fi > > are just awful. Actually if you factor out that isArr is a utility function (exactly like Push) that code is very easy to follow, as well as coping with all filenames, and itself would be part of a lib function. The only reason to have the check is for backward-compatibility, or to allow people to use whichever they feel most comfortable with. One might not know how to count/use arrays in BASH, fair enough; that's how. Given that basic knowledge[1] of the tool used to write ebuilds since the very beginning, I cannot see how that is hard to follow. I'm willing to bet your sh scripts aren't really as portable as you think. If you want to see how portable sh is done, read: http://sources.redhat.com/autobook/autobook/autobook_210.html#SEC210 (all of it) and then try to persuade us that we should be writing ebuilds like that. If you want to do that kind of thing, much better imo to do another type of ebuild, eg a pbuild using Python, and only call sh when absolutely necessary, if at all. BTW, thanks for eix; it's a lovely utility. [1] http://wooledge.org/mywiki/BashFAQ/005