- Jun
- 27
- 0
I have a question about set. The docs for set says that "If you do not specify a filename and input is redirected, SET /R will read from stdin." But how does one redirect input without specifying a filename? The only way I know to do that is with a pipe. But this fails, as this demo shows.
[ C:\eric_p\bat ]
[0]>ver
TCC 9.02.152 Windows XP [Version 5.1.2600]
[ C:\eric_p\bat ]
[0]>type xyz.btm
@echo off
echo Demonstration script
echo 0 input params: %*
echo.
echo 1 piped to set
echo VAR1=PIPED %* | set /r
echo Value of var1 is (%var1)
echo.
echo 2 redirected to set
echo VAR2=REDIRECT %* > file && set /r < file
echo Value of var2 is (%var2)
del /q file
[ C:\eric_p\bat ]
[0]>xyz aa :bb: c=d -e-f-g
Demonstration script
0 input params: aa :bb: c=d -e-f-g
1 piped to set
Value of var1 is ()
2 redirected to set
Value of var2 is (REDIRECT aa :bb: c=d -e-f-g)
Any comments? It does appear as if set ought to accepted piped input, but that it does not. (That is, unless I have an old version of TCC that has a bug here.)
Eric
[ C:\eric_p\bat ]
[0]>ver
TCC 9.02.152 Windows XP [Version 5.1.2600]
[ C:\eric_p\bat ]
[0]>type xyz.btm
@echo off
echo Demonstration script
echo 0 input params: %*
echo.
echo 1 piped to set
echo VAR1=PIPED %* | set /r
echo Value of var1 is (%var1)
echo.
echo 2 redirected to set
echo VAR2=REDIRECT %* > file && set /r < file
echo Value of var2 is (%var2)
del /q file
[ C:\eric_p\bat ]
[0]>xyz aa :bb: c=d -e-f-g
Demonstration script
0 input params: aa :bb: c=d -e-f-g
1 piped to set
Value of var1 is ()
2 redirected to set
Value of var2 is (REDIRECT aa :bb: c=d -e-f-g)
Any comments? It does appear as if set ought to accepted piped input, but that it does not. (That is, unless I have an old version of TCC that has a bug here.)
Eric