bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: unwanted expansion of variable with nested strings


From: Aharon Robbins
Subject: Re: unwanted expansion of variable with nested strings
Date: Thu, 04 May 2006 17:29:38 +0300

In article <address@hidden> you write:
>On Thursday 04 May 2006 00:44, Paul Jarc wrote:
>> Mike Frysinger <address@hidden> wrote:
>> > $ foo="a b c"
>> > $ gawk 'BEGIN {foo="'${foo}'"}'
>> > gawk: BEGIN {foo="a
>> > gawk:            ^ unterminated string
>>
>> This is normal.  man bash:
>>
>> #   Word Splitting
>> #       The  shell  scans the results of parameter expansion, command
>> substitu- #       tion, and arithmetic expansion that did not occur within
>> double  quotes #       for word splitting.
>
>thanks, this is the bit i was unable to locate myself
>
>> > so if i quote ${foo} like so:
>> > $ gawk 'BEGIN {foo="'"${foo}"'"}'
>> > it'll work in this case, but then fail if foo contains newlines:
>> > foo="a
>> > b
>> > c"
>>
>> What do you mean by "fail"?  What do you want to happen in this case?
>
>i meant gawk hates it ... not bash
>-mike

Why are you surprised? This is the definition of the awk language, that
unescaped newlines inside a string are a syntax error. The same is true
of C and C++.  Any awk will produce an error, not just gawk.

Arnold
-- 
Aharon (Arnold) Robbins --- Pioneer Consulting Ltd.     arnold AT skeeve DOT com
P.O. Box 354            Home Phone: +972  8 979-0381    Fax: +1 206 350 8765
Nof Ayalon              Cell Phone: +972 50  729-7545
D.N. Shimshon 99785     ISRAEL




reply via email to

[Prev in Thread] Current Thread [Next in Thread]