tribble:~> perl -E'say $ARGV[0]' "`/bin/echo -e 'foo\nbar'`"
foo
tribble:~> perl -E'say $ARGV[0]' "`/bin/echo -e \"foo\nbar\"`"
Unmatched '`'.
I stopped using tcsh 20 years ago because it was a horrible shell for programming.
| [reply] [d/l] [select] |
Thanks, ikegami, for trying that, I don't have tcsh installed, so couldn't check. (I'm pretty sure my quoting in the backtick command substitution is "more correct" (if as ineffective) than the OP's ;-) In the 90s I had a small niche specialty tangential to my main programming job: I rewrote csh scripts as ksh, I definitely empathize with your distaste for tcsh!
The rest of my thoughts
This tcsh behavior smells like there is one final string expansion looking for newlines inside the shell before gunkulating. If that is the case, the OP might succeed with something that adds another layer of quoting like
\""`/bin echo -e \"foo\\\n\bar\"`"\"
Yuck.
Using a pure Bourne-descended shell doesn't satisfy the tcsh requirement, but I think it's instructive to see that the nestable command substitution, $(), eliminates the need for escaping the quoting:
perl -E'say $ARGV[0]' "$(/bin/echo -e "foo\nbar")"
foo
bar
(Now that I could, and did, test in my console.)
A lot of perl scripts are launched via wrapper shell scripts, so I always appreciated when these nooks and crannies are explored in PM, since being good at that made it easier to do my job. | [reply] [d/l] [select] |
tribble:~> perl -E'say $ARGV[0]' \""`/bin echo -e \"foo\\\n\bar\"`"\"
Unmatched '`'.
| [reply] [d/l] |