cbrandtbuffalo has asked for the wisdom of the Perl Monks concerning the following question:

In a typical unix shell, you can type a multiline command using \, that is:
shell>some -really -long -command 'string\ more string stuff'
I'm trying to build a test using Test::Expect, but I'm finding it hard to duplicate the above.

I tried a few variations and
expect_send(qq{some -command 'string stuff\\ \cM more on next line'}, +"Testing...");
seems to send the right stuff, escaping and sending a '\', then a newline. But I think Expect.pm is getting confused because it seems to treat the second part of the command as the expected output.

Is there a standard way to do this? Who's getting confused, Test::Expect, Expect::Simple, or Expect.pm?

Update:One other question: even if I get this working, will this test only work in some shells? That is, if I wanted it to be multi-platform, would I need multiple versions of the test?

Update:Modified example to show that the newline is inside a quoted string.

Thanks for any suggestions.

Replies are listed 'Best First'.
Re: Expect.pm and multiline commands
by Tomte (Priest) on Sep 28, 2006 at 13:48 UTC

    IIRC

    shell>some -really -long -command \ -with -many -options

    is actualy one line - the newline character is consumed and not part of the executed command.

    compare

    tomte@librics-tomte ~ $ echo "test eins" test eins
    to
    tomte@librics-tomte ~ $ echo "test\ eins" testeins

    regards,
    tomte


    An intellectual is someone whose mind watches itself.
    -- Albert Camus

      I should clarify my example because the case I'm trying to test actually matches your example. That is, I want to test a string passed to an option and the string should pass along the new line.

      I think your example may have answered my question about different shells. I use tcsh and I get:
      >echo "test\ ? stuff" test stuff >echo "test Unmatched ".