1 |
Donnie Berkholz wrote: |
2 |
> On 10:51 Fri 05 Oct , Bernard Cafarelli (voyageur) wrote: |
3 |
>> 1.4 eclass/gnustep-base.eclass |
4 |
>> |
5 |
>> file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/gnustep-base.eclass?rev=1.4&view=markup |
6 |
>> plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/gnustep-base.eclass?rev=1.4&content-type=text/plain |
7 |
>> diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/gnustep-base.eclass?r1=1.3&r2=1.4 |
8 |
> |
9 |
>> @@ -166,8 +166,43 @@ |
10 |
>> |
11 |
>> local cfile=config-${PN}.sh |
12 |
>> |
13 |
>> - echo '#!/usr/bin/env bash' > "${T}"/${cfile} |
14 |
>> - echo "echo Applying ${P} default configuration ..." >> "${T}"/${cfile} |
15 |
>> + cat << EOF > "${T}"/${cfile} |
16 |
>> +#!/usr/bin/env bash |
17 |
>> +gnustep_append_default() { |
18 |
>> + if [[ -z \$1 || -z \$2 || -z \$3 ]]; then |
19 |
>> + echo "warning: invalid script invocation" |
20 |
>> + return |
21 |
>> + fi |
22 |
>> + dom=\$1 |
23 |
>> + key=\$2 |
24 |
>> + val=\$3 |
25 |
>> + cur=\$(defaults read \${dom} \${key}) 2> /dev/null |
26 |
>> + if [[ -z \$cur ]] ; then |
27 |
>> + echo " * setting \${dom} \${key}" |
28 |
>> + defaults write \${dom} \${key} "( \${val} )" |
29 |
>> + elif [[ \${cur} != *\${val}* ]] ; then |
30 |
>> + echo " * adding \${val} to \${dom} \${key}" |
31 |
>> + echo "\${cur%)\'}, \"\${val}\" )'" | defaults write |
32 |
>> + else |
33 |
>> + echo " * \${val} already present in \${dom} \${key}" |
34 |
>> + fi |
35 |
>> +} |
36 |
>> + |
37 |
>> +gnustep_set_default() { |
38 |
>> + if [[ -z \$1 || -z \$2 || -z \$3 ]]; then |
39 |
>> + echo "warning: invalid script invocation" |
40 |
>> + return |
41 |
>> + fi |
42 |
>> + dom=\$1 |
43 |
>> + key=\$2 |
44 |
>> + val=\$3 |
45 |
>> + echo " * setting \${dom} \${key}" |
46 |
>> + defaults write \${dom} \${key} \${val} |
47 |
>> +} |
48 |
>> + |
49 |
>> +echo "Applying ${P} default configuration ..." |
50 |
>> +EOF |
51 |
>> + |
52 |
> |
53 |
> There's gotta be a better way of doing this. All those escapes really |
54 |
> start to obfuscate the code. Anyone got a better idea? |
55 |
> |
56 |
> Thanks, |
57 |
> Donnie |
58 |
|
59 |
If there aren't any variables that you actually need expanded in the |
60 |
script (i didn't see any but could have easily missed it), just escape |
61 |
the termination marker, ie. |
62 |
|
63 |
cat << \EOF > "${T}"/${cfile} |
64 |
|
65 |
or |
66 |
cat << 'EOF' > "${T}"/${cfile} |
67 |
|
68 |
This turns off parameter and arithmetic expansion and command |
69 |
substitution. |
70 |
|
71 |
-- |
72 |
fonts / wxWindows / gcc-porting / treecleaners |
73 |
EFFD 380E 047A 4B51 D2BD C64F 8AA8 8346 F9A4 0662 (0xF9A40662) |
74 |
|
75 |
-- |
76 |
gentoo-dev@g.o mailing list |