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)

-- 
[EMAIL PROTECTED] mailing list

Reply via email to