in reply to Re^4: passing newline in string argument
in thread passing newline in string argument

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.

Replies are listed 'Best First'.
Re^6: passing newline in string argument
by ikegami (Patriarch) on Aug 02, 2025 at 18:27 UTC
    tribble:~> perl -E'say $ARGV[0]' \""`/bin echo -e \"foo\\\n\bar\"`"\" Unmatched '`'.