From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists.gentoo.org ([140.105.134.102] helo=robin.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1IhnIL-0006SV-8t for garchives@archives.gentoo.org; Tue, 16 Oct 2007 14:21:17 +0000 Received: from robin.gentoo.org (localhost [127.0.0.1]) by robin.gentoo.org (8.14.1/8.14.0) with SMTP id l9GEA8WW029354; Tue, 16 Oct 2007 14:10:08 GMT Received: from mail.marples.name (rsm.demon.co.uk [80.177.111.50]) by robin.gentoo.org (8.14.1/8.14.0) with ESMTP id l9GE8JmT027012 for ; Tue, 16 Oct 2007 14:08:19 GMT Received: from [10.73.1.31] (uberlaptop.marples.name [10.73.1.31]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) by mail.marples.name (Postfix) with ESMTP id D82AD190038 for ; Tue, 16 Oct 2007 15:08:17 +0100 (BST) Subject: Re: [gentoo-dev] Re: Re: Re: [gentoo-commits] gentoo-x86 commit in dev-php5/onphp: ChangeLog onphp-0.10.6.ebuild onphp-0.10.4.ebuild onphp-0.10.3.ebuild From: Roy Marples To: gentoo-dev@lists.gentoo.org In-Reply-To: References: <20071014211125.GB23990@supernova> <20071014235246.GA19544@phaenix.haell.com> <20071015022506.461cea64@eusebe> <20071016072812.GT23990@supernova> <1192520674.3687.1.camel@uberpc.marples.name> Content-Type: text/plain Organization: Gentoo Date: Tue, 16 Oct 2007 15:08:16 +0100 Message-Id: <1192543696.1173.18.camel@uberlaptop.development.ltl> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@gentoo.org Reply-to: gentoo-dev@lists.gentoo.org Mime-Version: 1.0 X-Mailer: Evolution 2.10.3 Content-Transfer-Encoding: 7bit X-Archives-Salt: 4cc24f25-c3ca-46ce-95b9-13b085d721b4 X-Archives-Hash: cdedaaf0274491b77afe8f2c776a1d1c On Tue, 2007-10-16 at 13:38 +0100, Steve Long wrote: > Roy Marples wrote: > > On Tue, 2007-10-16 at 00:28 -0700, Donnie Berkholz wrote: > >> On 08:19 Tue 16 Oct , Steve Long wrote: > >> > stdDocs=(ChangeLog AUTHORS FEATURES THANKS README CodingStyle TODO FAQ) > >> > > >> > stdDoc() { > >> > local d l=() > >> > for d in "${stdDocs[@]}"; do > >> > [[ -f $d ]] && l+=("$d") > >> > done > >> > ((${#l[@]})) && dodoc "${l[@]}" > >> > } > >> > > >> > (assuming [[ $PWD = $S ]] or whichever is the right one for docs.) > >> > >> Is it just me, or is this code way more complex than it needs to be? It > >> looks like bashturbation to me. =P > > > LMAO. It's as complex as it needs to be to handle filenames with spaces or > any other character in. Remember: "Looks like it needs quotes there.. $D, > $S.." What, I should write crap script for this esteemed audience, cos you > only currently deal with filenames without spaces? ;P No, it's overly complex. Consider this stddoc() { local d for d in ChangeLog AUTHORS FEATURES THANKS README \ CodingStyle TODO FAQ; do [ -f "${d}" ] && dodoc "${f}" done } Want spaces? stddoc() { local d for d in ChangeLog AUTHORS FEATURES THANKS README \ CodingStyle TODO FAQ "a file with spaces"; do [ -f "${d}" ] && dodoc "${f}" done } Or maybe you want to do it on one hit? stddoc() { local d set -- for d in ChangeLog AUTHORS FEATURES THANKS README \ CodingStyle TODO FAQ "a file with spaces"; do [ -f "${d}" ] && set -- "$@" "${f}" done dodoc "$@" } > > You can also do some pattern matching like so > > > > foo="foo foobar" > > > > [ "${foo%foobar}" = "${foo}" ] || echo "ends with foobar" > [[ $foo = *foobar ]] && echo "ends with foobar" > > > [ "${foo#foobar}" = "${foo}" ] || echo "starts with foo" > [[ $foo = foo* ]] && echo 'oh does it?' > There's no need for borked script that is counter-intuitive, and doesn't > have a third of the functionality either. I maybe wrong, but shouldn't you be using == inside [[ ]]? > [[ $foo = *'wow it '*"does as $well"* ]] && echo 'And a whole lot more!' case "${foo}" in *'wow it '*"does as $well"*) && echo "whatever you can do i can do in sh";; esac > Or should *nix only ever support > POSIX APIs for everything? #define _X_OPEN_SOURCE? No? Hmm.. *shrug* ;> No, I saying use whatever god given extensions you like. But if there's a portable way of doing the same thing then please use the portable way of doing it. > /me wanders down the pub.. *plop* Yeah, I'd drown my sorrows if I wrote shell script like you :P Thanks Roy -- gentoo-dev@gentoo.org mailing list