* [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in eclass: gnustep-base.eclass [not found] <E1Idkm9-0003dm-4y@stork.gentoo.org> @ 2007-10-05 18:03 ` Donnie Berkholz 2007-10-05 18:12 ` Fabian Groffen ` (3 more replies) 0 siblings, 4 replies; 7+ messages in thread From: Donnie Berkholz @ 2007-10-05 18:03 UTC (permalink / raw To: gentoo-dev, voyageur On 10:51 Fri 05 Oct , Bernard Cafarelli (voyageur) wrote: > 1.4 eclass/gnustep-base.eclass > > file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/gnustep-base.eclass?rev=1.4&view=markup > plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/gnustep-base.eclass?rev=1.4&content-type=text/plain > diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/gnustep-base.eclass?r1=1.3&r2=1.4 > @@ -166,8 +166,43 @@ > > local cfile=config-${PN}.sh > > - 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? Thanks, Donnie -- gentoo-dev@gentoo.org mailing list ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in eclass: gnustep-base.eclass 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 2007-10-05 18:50 ` George Shapovalov ` (2 subsequent siblings) 3 siblings, 0 replies; 7+ messages in thread From: Fabian Groffen @ 2007-10-05 18:12 UTC (permalink / raw To: gentoo-dev 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 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in eclass: gnustep-base.eclass 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 @ 2007-10-05 18:50 ` George Shapovalov 2007-10-05 19:47 ` Roy Marples 2007-10-05 23:31 ` Ryan Hill 3 siblings, 0 replies; 7+ messages in thread From: George Shapovalov @ 2007-10-05 18:50 UTC (permalink / raw To: gentoo-dev Friday, 5. October 2007, Donnie Berkholz Ви написали: > There's gotta be a better way of doing this. All those escapes really > start to obfuscate the code. Anyone got a better idea? Just use single quotes? This should prevent bash expansion. Although, as I can see, this is done in here-function, so it is better to test first (which is a good idea in any case :)), but I don't see right away why that would not work.. George -- gentoo-dev@gentoo.org mailing list ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in eclass: gnustep-base.eclass 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 2007-10-05 18:50 ` George Shapovalov @ 2007-10-05 19:47 ` Roy Marples 2007-10-05 23:31 ` Ryan Hill 3 siblings, 0 replies; 7+ messages in thread From: Roy Marples @ 2007-10-05 19:47 UTC (permalink / raw To: gentoo-dev On Fri, 2007-10-05 at 11:03 -0700, Donnie Berkholz wrote: > There's gotta be a better way of doing this. All those escapes really > start to obfuscate the code. Anyone got a better idea? Create a dir in eclasses to store proper files. Then just copy it from there. We store real patches in ELT-patches. Thanks Roy -- gentoo-dev@gentoo.org mailing list ^ permalink raw reply [flat|nested] 7+ messages in thread
* [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in eclass: gnustep-base.eclass 2007-10-05 18:03 ` [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in eclass: gnustep-base.eclass Donnie Berkholz ` (2 preceding siblings ...) 2007-10-05 19:47 ` Roy Marples @ 2007-10-05 23:31 ` Ryan Hill 2007-10-06 0:08 ` Donnie Berkholz 3 siblings, 1 reply; 7+ messages in thread From: Ryan Hill @ 2007-10-05 23:31 UTC (permalink / raw To: gentoo-dev Donnie Berkholz wrote: > On 10:51 Fri 05 Oct , Bernard Cafarelli (voyageur) wrote: >> 1.4 eclass/gnustep-base.eclass >> >> file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/gnustep-base.eclass?rev=1.4&view=markup >> plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/gnustep-base.eclass?rev=1.4&content-type=text/plain >> diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/gnustep-base.eclass?r1=1.3&r2=1.4 > >> @@ -166,8 +166,43 @@ >> >> local cfile=config-${PN}.sh >> >> - 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? > > Thanks, > Donnie If there aren't any variables that you actually need expanded in the script (i didn't see any but could have easily missed it), just escape the termination marker, ie. cat << \EOF > "${T}"/${cfile} or cat << 'EOF' > "${T}"/${cfile} This turns off parameter and arithmetic expansion and command substitution. -- fonts / wxWindows / gcc-porting / treecleaners EFFD 380E 047A 4B51 D2BD C64F 8AA8 8346 F9A4 0662 (0xF9A40662) -- gentoo-dev@gentoo.org mailing list ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in eclass: gnustep-base.eclass 2007-10-05 23:31 ` Ryan Hill @ 2007-10-06 0:08 ` Donnie Berkholz 2007-10-07 22:43 ` Bernard Cafarelli 0 siblings, 1 reply; 7+ messages in thread From: Donnie Berkholz @ 2007-10-06 0:08 UTC (permalink / raw To: gentoo-dev On 17:31 Fri 05 Oct , Ryan Hill wrote: > If there aren't any variables that you actually need expanded in the > script (i didn't see any but could have easily missed it), just escape > the termination marker, ie. > > cat << \EOF > "${T}"/${cfile} > > or > cat << 'EOF' > "${T}"/${cfile} > > This turns off parameter and arithmetic expansion and command > substitution. That is so cool. Just another reason I love this reviewing. Thanks, Donnie -- gentoo-dev@gentoo.org mailing list ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in eclass: gnustep-base.eclass 2007-10-06 0:08 ` Donnie Berkholz @ 2007-10-07 22:43 ` Bernard Cafarelli 0 siblings, 0 replies; 7+ messages in thread From: Bernard Cafarelli @ 2007-10-07 22:43 UTC (permalink / raw To: gentoo-dev Le Fri, 5 Oct 2007 17:08:17 -0700 Donnie Berkholz <dberkholz@gentoo.org> a écrit: > On 17:31 Fri 05 Oct , Ryan Hill wrote: > > If there aren't any variables that you actually need expanded in the > > script (i didn't see any but could have easily missed it), just escape > > the termination marker, ie. > > > > cat << \EOF > "${T}"/${cfile} > > > > or > > cat << 'EOF' > "${T}"/${cfile} > > > > This turns off parameter and arithmetic expansion and command > > substitution. > > That is so cool. Just another reason I love this reviewing. Yes, thanks for the suggestion, this looks perfect! These lines originally had some ${GNUSTEP_...} variables in them, which required expansion in the ebuild, hence the backquotes forest... Now, however the only one here is ${P}, which will probably be left alone in its own echo command. I'll look into that soon. By the way, even if this probably won't be need in that case, what's the policy on adding files for eclasses, as uberlord suggested? The only subfolder in eclasses/ for now is ELT-patches, but maybe because for now no eclass needed that feature -- Bernard Cafarelli (Voyageur) NX and GNUstep Gentoo developer -- gentoo-dev@gentoo.org mailing list ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2007-10-07 22:57 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [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 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
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox