how to work with env var with special characters in the name

Jun 3, 2008
130
3
Temecula, CA
I've got a strange program that creates some environment variables that have <> around the name, for example, one might be named <test>. How do I get the value of this environment variable? I couldn't seem to figure out anything, not even using the SETDOS /x-6. Note that the solution needs to be compatible with the current TCC v15, and also with 4nt v6.
 
May 20, 2008
3,515
4
Elkridge, MD, USA
I would try the form %[<test>] which was available in 4nt6 (IIRC); probably combined with SETDOS /X-6. That form may override the parser's rules for separating tokes, but no guarantees, not tested...
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,466
88
Albuquerque, NM
prospero.unm.edu
I would try the form %[<test>] which was available in 4nt6 (IIRC); probably combined with SETDOS /X-6. That form may override the parser's rules for separating tokes, but no guarantees, not tested...


I think, if you do it that way, you don't need the SETDOS -- TCC doesn't check for redirections inside the brackets. (But if the value of the variable contains weird values, then you'll still need SETDOS.)
 
Jun 3, 2008
130
3
Temecula, CA
I think, if you do it that way, you don't need the SETDOS -- TCC doesn't check for redirections inside the brackets. (But if the value of the variable contains weird values, then you'll still need SETDOS.)

That doesn't bear out in TCC 15.x. I didn't bother to check in 4nt 6.

->setdos
ANSI=0
COMPOUND=&
DESCRIPTIONS=1 (DESCRIPT.ION)
ESCAPE=^
EVAL=0.10
EXPANSION=0
MODE=1
NOCLOBBER=0
PARAMETERS=$
CURSOR OVERSTRIKE=10
CURSOR INSERT=100
VERBOSE=0

[Sun 7/21/13 @ 13:51:23]:
*** C:\ ***
->set [<x>]=test
TCC: (Sys) The system cannot find the file specified.
"C:\x"
 
May 20, 2008
11,411
99
Syracuse, NY, USA
I think Charles was referring to accessing the variable ... and that you'll have to use other means when setting it. For example,
Code:
v:\> set ^<x^>=foo
 
v:\> echo %[<x>]
foo
 
v:\> set
<x>=foo
*** SNIP ***
 
Similar threads
Thread starter Title Forum Replies Date
noahcoad How to? Create shortcut with env var in path Support 4
L WAD ECHO. expansion of non-existent env-vars differs from CMD.exe Support 6
M How to make Lua modify env-vars Support 18
D Redirection to clip - env dependency? Support 3
C Env vars in tcmd.ini Support 12
N Can't set an env variable via pipe Support 8
M Fixed Set "VAR=VAL" format causes problems Support 12
vefatica SET /A var=expression=digits Support 3
vefatica SET /A var\=...? Support 10
J WAD "setarray /f" only overwrites the first array var Support 2
Alpengreis TCC-Option for EnableDelayedExpansion (!var!) problem Support 15
vefatica SET /A "var%=N", TCC vs. CMD Support 0
D Minor problem. Incorrect value internal var _dir_files Support 7
N Problem with 'do <var> /L ....' and spaces Support 6
J Problem with %var:find=replace% syntax Support 5
A Bug report: Inkey /w %var Support 2
C writing folder names with JPSoft special chars like &...... Support 4
R How to? Set default application in a special folder Support 4
vefatica What's special about year 3000? Support 14
vefatica Quoting file names with special characters? Support 7
vefatica Display of special characters in aliases. Support 25
vefatica Fixed Escaping special characters Support 1
C How to? tell is @full[filename] contains any special JPSosft special chars Support 1
U Keystack mangles 'special' characters Support 6
vefatica Is the tilde special? Support 1
T How do you echo lines with special characters to file? Support 4

Similar threads