Re: unwanted expansion of variable with nested strings
On Thursday 04 May 2006 00:44, Paul Jarc wrote: Mike Frysinger [EMAIL PROTECTED] 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 ___ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash
Re: unwanted expansion of variable with nested strings
A little more bash syntax can quote newlines for awk. $ foo=a b c $ lf= $ gawk 'BEGIN {foo='${foo//$lf/\\n}'} END {print foo}' /dev/null a b c -- Mike Stroyan [EMAIL PROTECTED] ___ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash
Re: unwanted expansion of variable with nested strings
On Thursday 04 May 2006 11:08, Mike Stroyan wrote: A little more bash syntax can quote newlines for awk. this is when you start using gawk -v foo=$foo ... i was using gawk as an example of my variable expansion question, not as a way to figure out how to pass a variable into gawk -mike ___ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash
Re: unwanted expansion of variable with nested strings
On Thursday 04 May 2006 11:37, Paul Jarc wrote: Mike Frysinger [EMAIL PROTECTED] wrote: On Thursday 04 May 2006 00:44, Paul Jarc wrote: What do you mean by fail? What do you want to happen in this case? i meant gawk hates it ... not bash Ok, and what about the second question? there is no second answer as i stated in other followups in this thread -mike ___ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash
unwanted expansion of variable with nested strings
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: foo=a b c -mike ___ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash
Re: unwanted expansion of variable with nested strings
Mike Frysinger [EMAIL PROTECTED] 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. 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? paul ___ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash