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.


In reply to Re^5: passing newline in string argument by jaredor
in thread passing newline in string argument by Special_K

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.