Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

1>file (for ...

May
12,846
164
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.
 
On Wed, 04 Jun 2008 13:16:13 -0500, you wrote:


>vefatica wrote:
>
>
>---Quote---
>> 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.
>---End Quote---
>Your redirection syntax is meaningless - what are you actually trying to do?

How is it meaningless? It works (TCC):

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

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


> >> 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.
> >---End Quote---
> >Your redirection syntax is meaningless - what are you actually trying
> to do?
>
> How is it meaningless? It works (TCC):
>
> v:\> 1>file (date /t)
>
> v:\> type file
> Wed 2008-06-04

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
 
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
[email protected]
cc

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






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


Quote:

>vefatica wrote:
>
>
>---Quote---
>> 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.
>---End Quote---
>Your redirection syntax is meaningless - what are you actually trying to
do?
How is it meaningless? It works (TCC):

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

v:\> type file
Wed 2008-06-04
--
- Vince
 
On Wed, 04 Jun 2008 13:59:22 -0500, you wrote:


>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

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
 
Back
Top