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

How to? Avoid expansion and escaping

Discussion in 'Support' started by noahcoad, Apr 16, 2013.

  1. noahcoad

    Joined:
    Apr 29, 2009
    Messages:
    35
    Likes Received:
    0
    I have a .ini file with a value like this:
    this %is% || a `parameter` %+ another %= && another 'abc';

    I'm reading the line @iniread. How can I set this verbatim to an environment variable, then echo that environment variable value, then pass it as a parameter to another program? (without ever interpreting the line)
     
  2. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,859
    Likes Received:
    83
    @INIREAD doesn't care about special characters. But you'll want to turn off nested variable expansion (SETDOS /X-4) so TCC doesn't try to expand the variables in the returned value.

    If you want to echo it (why?) you can use ECHOX, which doesn't do any variable expansion, redirection, multiple commands, or compound commands.

    If you want to pass it to another program you'll have to use SETDOS /X-35 to turn off variable expansion and multiple commands / conditional commands / piping. (Maybe add 7 to ignore quoting too.)
     
  3. noahcoad

    Joined:
    Apr 29, 2009
    Messages:
    35
    Likes Received:
    0
    Almost there... How can I pass this strange line in a variable (a) to another command without the %is% expanding?

    [​IMG]

    And yes, the @iniread works fine, was just an example of getting a line with special characters, I'm also using @fileread, @line, and @xmlxpath. The echo is to be able to see the line on the console as part of the script. Attached are the files shown.
     

    Attached Files:

  4. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    Try using Charles Dye's SafeChars.dll, in particular, function @SafeLine.
     
  5. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,859
    Likes Received:
    83
    You should be using ECHOX, not ECHO.
     
  6. nikbackm

    Joined:
    May 30, 2008
    Messages:
    194
    Likes Received:
    1
    Can you use ECHOX to display a variable? (Would be useful!)

    I thought it was limited to literal strings.
     
  7. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,859
    Likes Received:
    83
    ECHOX will not display variables (or any other special processing) -- but the OP didn't *want* to display variables.
     

Share This Page