1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Command Line Quotiing Problem

Discussion in 'Support' started by Roedy, Jun 8, 2008.

  1. Roedy

    Joined:
    Jun 8, 2008
    Messages:
    120
    Likes Received:
    2
    I wrote a litte program to explore what happens to interfere with characters on the command line passed to a progam. The source code is available at
    http://mindprod.com/jgloss/commandline.html

    Here are some puzzling results:

    [C:\]java com.mindprod.example.TestParms "a b"
    1 parameter
    {a b}
    --done--

    [C:\]java com.mindprod.example.TestParms " \" "
    1 parameter
    { " }
    --done--

    [C:\]java com.mindprod.example.TestParms " > "
    1 parameter
    { > }
    --done--

    [C:\]java com.mindprod.example.TestParms " \" > "
    TCC: (Sys) The system cannot find the file specified.

    The puzzles:
    1. the use of \" is not documented
    2. > is sometimes treated literally and sometimes treated as redirection.

    How do you quote a complex parm like a REGEX that may contain the kitchen sink " \ < > $? ; ` ? | &

    I am using TCC 9.02.151 Windows Vista [Version 6.0.6001]
     
  2. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,883
    Likes Received:
    29
    On Sun, 08 Jun 2008 22:38:57 -0500, you wrote:


    The trouble here is that while \ escapes the " as far as Java is concerned, it
    doesn't in TCC. In the example above, TCC sends " \" to the program and tries
    to set up redirection (which fails). I can overcome the difficulty (with a "C"
    test program) like this.

    v:\> u:\EchoArgs.exe `" \" > "`
    u:\EchoArgs.exe (argv[0])
    " > (argv[1], which has a trailing space)

    Strong quotes (`) protect everything from TCC (except the action of TCC's escape
    character (^)) and are not passed to the app. So for example (again with "C")

    v:\> u:\EchoArgs.exe `" > < \" ^` | ^^"`
    u:\EchoArgs.exe
    > < " ` | ^ (all one arg)
    --
    - Vince
     

Share This Page