From: Fabian Groffen <grobian@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Subject: Re: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in eclass: gnustep-base.eclass
Date: Fri, 5 Oct 2007 20:12:15 +0200 [thread overview]
Message-ID: <20071005181215.GK15541@gentoo.org> (raw)
In-Reply-To: <20071005180356.GK29572@supernova>
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
next prev parent reply other threads:[~2007-10-05 18:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <E1Idkm9-0003dm-4y@stork.gentoo.org>
2007-10-05 18:03 ` [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in eclass: gnustep-base.eclass Donnie Berkholz
2007-10-05 18:12 ` Fabian Groffen [this message]
2007-10-05 18:50 ` George Shapovalov
2007-10-05 19:47 ` Roy Marples
2007-10-05 23:31 ` Ryan Hill
2007-10-06 0:08 ` Donnie Berkholz
2007-10-07 22:43 ` Bernard Cafarelli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20071005181215.GK15541@gentoo.org \
--to=grobian@gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox