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

DO /L and quoted arguments?

Discussion in 'TCC/LE Support' started by AnrDaemon, May 9, 2017.

  1. AnrDaemon

    Joined:
    Aug 23, 2010
    Messages:
    33
    Likes Received:
    1
    I just stumbled upon a problem. I wanted to process some strings passed as parameters, but the result was somewhat unexpected.
    I've reduced the issue to this Simple Test Case:
    Code:
    SET i=0
    DO EXT IN /L .sh ".bad sh"
      SET i=%@EVAL[%i+1]
      IFF "%@LEFT[1,%[EXT]]" == "." THEN
        ECHO "%[EXT]"
      ENDIFF
    ENDDO
    ECHO Did %i runs.
    Contrary to the expectation, the cycle runs 3 times and only display one extension. (The latter is not actually suprising, considering the former.)

    Is this considered normal behavior?
     
  2. samintz

    samintz Scott Mintz

    Joined:
    May 20, 2008
    Messages:
    1,188
    Likes Received:
    11
    The parameters following DO x IN /L are strings, not filenames. Each parameter will be assigned in sequence, from left to right, to the loop control variable on consecutive passes through the loop. /L will not treat double quotes as delimiters; use /Q if you want to pass arguments with embedded white space.
    Code:
    do e in /l .sh ".bad sh" (echo %e)
    .sh
    ".bad
    sh"
    
    do e in /q .sh ".bad sh" (echo %e)
    .sh
    ".bad sh"
    
     
  3. AnrDaemon

    Joined:
    Aug 23, 2010
    Messages:
    33
    Likes Received:
    1
    There's no /Q option for TCC/LE
    Code:
    [~\Documents\Bugs\TCC]$ "do-_Q-stc.btm"
    
    TCC LE  14.00.9 x64   Windows 7 [Version 6.1.7601]
    Did 0 runs.
    And RT doesn't unquote parameters.
     
  4. samintz

    samintz Scott Mintz

    Joined:
    May 20, 2008
    Messages:
    1,188
    Likes Received:
    11
    You could use @unquote to unquote the parameters.
    Code:
    do e in /q .sh ".bad sh" (echo %@unquote[%e])
    .sh
    .bad sh
    
     
  5. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,808
    Likes Received:
    82
    /Q was added in TCC 16.
     
  6. AnrDaemon

    Joined:
    Aug 23, 2010
    Messages:
    33
    Likes Received:
    1
    Yes, I know. It's just extra work when I already explicitly know that paramerets may have been quoted.
    And it is @UNQUOTES[] rather than @UNQUOTE[], since the latter destroys inner quoting of the string.
     

Share This Page