[Top][All Lists]

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

unwanted expansion of variable with nested strings

From: Mike Frysinger
Subject: unwanted expansion of variable with nested strings
Date: Wed, 3 May 2006 22:15:51 -0400
User-agent: KMail/1.9.1

ignoring the fact that i can pass in variables to gawk using the '-v' option, 
i'm wondering if this is a bug in how bash expands variables to pass to 
programs ... i couldnt pick out anything under EXPANSION, but that's probably 
just because i missed it ;)

take for example:
$ foo="a b c"
$ gawk 'BEGIN {foo="'${foo}'"}'
gawk: BEGIN {foo="a
gawk:            ^ unterminated string

this being because bash executed:
argv[0] = gawk
argv[1] = BEGIN {foo="a
argv[2] = b
argv[3] = c"}

when really i wanted:
argv[0] = gawk
argv[1] = BEGIN {foo="a b c"}

so if i quote ${foo} like so:
$ gawk 'BEGIN {foo="'"${foo}"'"}'
it'll work in this case, but then fail if foo contains newlines:

reply via email to

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