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
--
[EMAIL PROTECTED] mailing list