Mike Frysinger wrote:

> On Tuesday 11 December 2007, Denis Dupeyron wrote:
>> On Dec 11, 2007 6:03 AM, Mike Frysinger <[EMAIL PROTECTED]> wrote:
>> > On Monday 10 December 2007, Donnie Berkholz wrote:
>> > >       {
>> > >               ...
>> > >               echo "CONFIG_EAP_SAKE=y"
>> > >               ...
>> > >       } >> ${CONFIG}
>> >
>> > cat <<-EOF >> ${CONFIG}
>> > ...
>> > CONFIG_EAP_SAKE=y
>> > ...
>> > EOF
>>
>> Is what you are suggesting better ? If so, why ?
> 
> no scoping/subshells and obvious break between content (the stuff between
> EOF) and the commands to get it in there (no echos, just one cat)
++, although the filename should be quoted ("$CONFIG" or "${CONFIG}")
Also, in this case, there are no variables being expanded in the heredoc, so
it makes sense to quote 'EOF':
cat <<-'EOF' >> "$CONFIG"
...
EOF
(take off the - sign to keep indentation)

Personally I prefer using embedded multiline echo:
echo '
CONFIG_FOO
CONFIG_BAR
CONFIG_BLAH
' >> "$CONFIG"
since it avoids the fork of an external binary (double-quotes allow variable
expansion) but it is a bashism iirc.


-- 
[EMAIL PROTECTED] mailing list

Reply via email to