Environment variables, set and input

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 ]

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 1 piped to set
echo VAR1=PIPED %* | set /r
echo Value of var1 is (%var1)
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.)


Charles Dye

Super Moderator
Staff member
May 20, 2008
Albuquerque, NM
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.
May 20, 2008
Syracuse, NY, USA
On Thu, 23 Oct 2008 18:55:34 -0500, "JP Software Forums" <neil@jpsoft.com>,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:


That will read from the console.
Similar threads
Thread starter Title Forum Replies Date
Peter Murschall v27.00.16/17: ENDLOCAL with exporting variables wipes out the complete Environment Support 2
Charles Dye Read-only environment variables wiped by SETLOCAL / ENDLOCAL Support 5
J Shell nesting level, and inherited environment variables Support 10
fpefpe Documentation environment variables Support 3
fpefpe How to? Environment Variables changed Support 2
daniel347x How to get Take Command to read in all current system environment variables that CMD.EXE sees? Support 13
vefatica What environment variables does IDE need? Support 3
T Is there a way to maintain the position in the environment list, while debugging? Support 10
D Unnecessary environment dependencies of TCC.EXE Support 3
T Portable Take Command installation for VDI environment Support 2
D v23 environment oddity Support 3
gschizas Take Command (Environment) doesn't show v2 ANSI colors Support 30
M Save the environment .. ;-) Support 2
J Set environment variable from stdout of command Support 3
nickles Passing a variable to a command w/o adding it to the local environment Support 7
vefatica Environment refresh? Support 0
rfaquino WAD Apparently a bug when expanding environment variable %ProgramFiles(x86) Support 2
B WAD environment variable in TCC.exe Support 2
SeoulBigChris Save Environment (Tabs) on Exit? Support 3
vefatica OT: Rex, how does CMD handle its environment? Support 0
M Updating environment variable from C++ fails erratically in version 14... Support 57
Frank problem with environment variable x86 vs. x64 Support 2
fpefpe volatile environment Support 5
D Environment in elevated process Support 1
Peter Bratton IDE environment window display Support 0
D Environment variable oddity Support 12
vefatica Got IDE's environment tab back Support 0
S blanks in environment variable paths Support 4
tinjaw Looking for best practice for custom environment on tabs Support 0
E Environment variable in tcmd.ini Support 14
I Environment variable in OPTION screen? Support 2
J trouble redirecting output to environment variable Support 7
S How to? best way to compose data for command to use out of presets/variables Support 1
Joe Caverly START Dialog usage of %_ variables Support 0
Joe Caverly Modified Variables in CMDebug/BDebugger Support 1
T How to? Show the values of batch variables on the TCC screen Support 21
J Escaped Characters and Variables Support 2
M Keywords for commands, functions, internal variables Support 3
D How to? How to show variables expanded in the log tab Support 3
U Variables _IFTP, _IFTPS: what about sftp connections? Support 2
M Verification re volatile variables... Support 41
Stefano Piccardi 14.01.33 unset doesn't complain about undefined variables Support 8
CWBillow Variables in shortcuts? Support 15
Frank WAD handling variables with $-prefix Support 14
cgunhouse Accessing variables set using SET /U or SET /S Support 3
G gosub variables Support 9
vefatica Leading spaces in array variables Support 13
V Set path permanently from within TCC? Support 3
S Debugger keeps breaking with no break point set. Support 1
Joe Caverly Set a batch variable (%1 - %n) when TCC is executing a batch file Support 5

Similar threads