Environment variables, set and input

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
#1
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
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,478
44
Albuquerque, NM
prospero.unm.edu
#2
If I'm not mistaken, piping to SET /R will set the variables ... in the right-hand shell, which exits when it reaches the end of the piped data. It "works", but does nothing useful.

The help file is referring to the SET /R < FILENAME syntax. I don't see that it offers anything that SET /R FILENAME doesn't, though.
 
#3
On Thu, 23 Oct 2008 18:55:34 -0500, "JP Software Forums" <[email protected]>,Eric
Pement <> wrote:


>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.
I think the help means a simple:

SET /R

That will read from the console.