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 1IdrqS-0000Gq-3E for garchives@archives.gentoo.org; Fri, 05 Oct 2007 18:24:16 +0000 Received: from robin.gentoo.org (localhost [127.0.0.1]) by robin.gentoo.org (8.14.1/8.14.0) with SMTP id l95IE9JB008916; Fri, 5 Oct 2007 18:14:09 GMT Received: from osiris.cheops.ods.org (osiris.cheops.ods.org [80.127.25.226]) by robin.gentoo.org (8.14.1/8.14.0) with ESMTP id l95ICG8h006635 for ; Fri, 5 Oct 2007 18:12:17 GMT Received: from tefnut.cheops.ods.org ([172.17.2.81] helo=gentoo.org) by osiris.cheops.ods.org with esmtps (TLSv1:AES256-SHA:256) (Exim 4.67) (envelope-from ) id 1Idreq-0002Gv-KM for gentoo-dev@lists.gentoo.org; Fri, 05 Oct 2007 20:12:16 +0200 Date: Fri, 5 Oct 2007 20:12:15 +0200 From: Fabian Groffen To: gentoo-dev@lists.gentoo.org Subject: Re: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in eclass: gnustep-base.eclass Message-ID: <20071005181215.GK15541@gentoo.org> Mail-Followup-To: gentoo-dev@lists.gentoo.org References: <20071005180356.GK29572@supernova> 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 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20071005180356.GK29572@supernova> User-Agent: Mutt/1.5.16 (Darwin 8.10.0, VIM - Vi IMproved 7.1) Organization: Gentoo Foundation, Inc. X-Archives-Salt: 12e37c58-01f4-465b-ba6f-f72647e24183 X-Archives-Hash: c375f461f0158758f00f81aeaef3b2a0 On 05-10-2007 11:03:56 -0700, Donnie Berkholz wrote: > > - echo '#!/usr/bin/env bash' > "${T}"/${cfile} > > - echo "echo Applying ${P} default configuration ..." >> "${T}"/${cfile} > > + cat << EOF > "${T}"/${cfile} > > +#!/usr/bin/env bash > > +gnustep_append_default() { > > + if [[ -z \$1 || -z \$2 || -z \$3 ]]; then > > + echo "warning: invalid script invocation" > > + return > > + fi > > + dom=\$1 > > + key=\$2 > > + val=\$3 > > + cur=\$(defaults read \${dom} \${key}) 2> /dev/null > > + if [[ -z \$cur ]] ; then > > + echo " * setting \${dom} \${key}" > > + defaults write \${dom} \${key} "( \${val} )" > > + elif [[ \${cur} != *\${val}* ]] ; then > > + echo " * adding \${val} to \${dom} \${key}" > > + echo "\${cur%)\'}, \"\${val}\" )'" | defaults write > > + else > > + echo " * \${val} already present in \${dom} \${key}" > > + fi > > +} > > + > > +gnustep_set_default() { > > + if [[ -z \$1 || -z \$2 || -z \$3 ]]; then > > + echo "warning: invalid script invocation" > > + return > > + fi > > + dom=\$1 > > + key=\$2 > > + val=\$3 > > + echo " * setting \${dom} \${key}" > > + defaults write \${dom} \${key} \${val} > > +} > > + > > +echo "Applying ${P} default configuration ..." > > +EOF > > + > > There's gotta be a better way of doing this. All those escapes really > start to obfuscate the code. Anyone got a better idea? If you have it, let us know. We write bash code to a file here to be executed lateron. To give you some background; we first used separate echo statements, and found that this was the most readable form. One option may be using an echo ' code code ${bla} ' Honestly I forgot why we didn't do this. -- Fabian Groffen Gentoo on a different level -- gentoo-dev@gentoo.org mailing list