3 ms·
Sadly not: only quotes that appeared literally in the command-as-written affect word-splitting or are subject to quote removal, not those resulting from an expa
by EvilTerran 10y ago
Sadly not: only quotes that appeared literally in the command-as-written affect word-splitting or are subject to quote removal, not those resulting from an expansion step (variable substitution, globbing, etc); so you'd end up with four elements in argv (or one if you double-quoted the variable reference), with literal single-quote characters in them. You'd have to do something unpleasant with "eval" to make that work.
It's a sensible rule, when you think about it - otherwise, for example, an expansion that introduced mismatched quotes would cause total chaos.
- grymoire1 10y agoYou can include quotes in arguments on Unix systems. The only tricky bit is getting meta-characters past the shell to the command the shell executes. Example #!/bin/bash Q1="'" Q2='"' echo "$Q1$Q2" This prints '" And if you really understand that ' and " turn quoting on and off anywhere in the line, you can combine these two into a single variable: #!/bin/bash Q1="'"'"' echo "$Q1"
- EvilTerran 10y agoYeah, that's the very behaviour I'm talking about - it just happens to be a problem in this particular case: the single-quotes in hk__2's PROPS variable would be passed to the executed command, not interpreted by the shell, but we wanted the latter here.