Re: shell quoting around script output



On 1/12/2012 6:23 PM, Kaz Kylheku wrote:
On 2012-01-12, Ed Morton<mortonspam@xxxxxxxxx> wrote:
Yes, I know but I don't think that answers my question of why this:

$ awk "$(cat<<"end"
BEGIN{ print "Hello World" }
end
)"

behaves like this (double quotes around $(..) replaced by single quotes):

$ awk 'BEGIN{ print "Hello World" }'

<stuff I already know snipped>
The $(...) will take the output of cat (the here document) and turn it into a
one big string, which is prevented from word splitting or globs because it
is in quotes, causing it to be passed to awk as one argument.

Is that the definitive answer then? That the script that is output from $(...) is not subject to word splitting and so is passed to awk as one argument and that is exactly the same behavior as enclosing a script in single quotes?

Or to put it another way, enclosing a script in single quotes works because that prevents word splitting, and using $(...) to generate a script works because that also prevents word splitting. Is that right?

Ed.
.



Relevant Pages

  • Applescript and Autoformat (search and replace), Word 2004
    ... script that will take care of a recurring editing issue with nested ... quotes to double quotes, ... set oldauto2 to auto format as you type replace quotes ... set auto format as you type replace quotes to false ...
    (microsoft.public.mac.office.word)
  • Re: Accessing full command line or parameters WITH QUOTES
    ... The problem is that VBScript doesn't allow access to the full command line ... rebuild the parameters with the quotes inserted properly. ... When I was writing the script on XP, I managed to cheat and grab the ...
    (microsoft.public.scripting.vbscript)
  • Re: shell quoting around script output
    ... behaves like this (double quotes around $(..) replaced by single quotes): ... which is prevented from word splitting or globs because it ... causing it to be passed to awk as one argument. ... That the script that is output from $ ...
    (comp.unix.shell)
  • Re: Database/Email Script
    ... Both double and single quotes work for quoting array indexes. ... the relevant code. ... What I would like first would be to get the script working. ... task as a learning experience.) ...
    (comp.lang.php)
  • Re: basic help to run an application from WSH
    ... string values must be enclosed in quotes. ... The Run method will execute on c:\notepad.exe. ... I'm just learning vbscript for wsh and here is my first script, ... Also if I cut and paste the exact file path from the script into the ...
    (microsoft.public.scripting.vbscript)