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

1>file (for ...

Discussion in 'Support' started by vefatica, Jun 4, 2008.

  1. vefatica

    Joined:
    May 20, 2008
    Messages:
    8,056
    Likes Received:
    30
    Why doesn't this work?

    v:\> 1>file (for /L %i in (0,1,2) do echo %i)
    Usage : FOR [/A:[[-][+] ...

    It works in CMD.EXE and with other TCC commands.
     
  2. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,994
    Likes Received:
    84
    vefatica wrote:

    Your redirection syntax is meaningless - what are you actually trying to do?

    Rex Conn
    JP Software
     
  3. vefatica

    Joined:
    May 20, 2008
    Messages:
    8,056
    Likes Received:
    30
    On Wed, 04 Jun 2008 13:16:13 -0500, you wrote:


    How is it meaningless? It works (TCC):

    v:\> 1>file (date /t)

    v:\> type file
    Wed 2008-06-04
    --
    - Vince
     
  4. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,994
    Likes Received:
    84
    vefatica wrote:


    First, it's meaningless because you're asking the parser to redirect
    STDOUT to STDOUT and then on to FILE. Lose the "1".

    The second problem is with the overall line syntax. Because you put the
    redirection at the beginning of the line (undocumented behavior), the
    parser has no way of knowing that you're (eventually) going to want to
    run a FOR, so it does variable expansion on the whole line, causing the
    %i arguments to be prematurely expanded. You either need to double up
    the %'s or eliminate the command grouping and put the redirection at the
    end of the line.

    Rex Conn
    JP Software
     
  5. samintz

    samintz Scott Mintz

    Joined:
    May 20, 2008
    Messages:
    1,201
    Likes Received:
    11
    Boy, talk about cryptic syntax! Do you have a need for that syntax? Why
    can't you use the more readable:

    (for /L %i in (0,1,2) do echo %i)>file

    -Scott




    vefatica <>
    06/04/2008 02:38 PM
    Please respond to



    To
    Samintz@ra.rockwell.com
    cc

    Subject
    RE: [Support-t-121] 1>file (for ...






    On Wed, 04 Jun 2008 13:16:13 -0500, you wrote:


    Quote:

    do?
    How is it meaningless? It works (TCC):

    v:\> 1>file (date /t)

    v:\> type file
    Wed 2008-06-04
    --
    - Vince
     
  6. vefatica

    Joined:
    May 20, 2008
    Messages:
    8,056
    Likes Received:
    30
    On Wed, 04 Jun 2008 13:59:22 -0500, you wrote:


    I don't find it cryptic or any less readable but I'm not lobbying for it either.
    I was just curious. I actually wanted to do "> NUL", but was at the beginning
    of the line. The construction (which I've known for a long time and which often
    works) popped into my head.

    1>nul for ...

    It didn't work (didn't work in CMD either). When I threw in the parens,

    1>nul (for ...

    It did work in CMD but not in TCC. So I thought I'd ask about it. I am not
    asking that any behavior be changed.

    --
    - Vince
     

Share This Page