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

Jun 3, 2008
137
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,689
106
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
137
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
12,171
133
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