DOS environment variable expansion defective?

Additional operating system/hardware discussion (Windows, Linux, *BSD and others)
Forum rules
Any posts concerning pirated software or offering to buy/sell/trade commercial software are subject to removal.
User avatar
Voralyan
Posts: 142
Joined: Wed Mar 05, 2008 12:28 pm
Location: Osnabrück, Germany

DOS environment variable expansion defective?

Unread postby Voralyan » Mon Nov 18, 2013 8:03 am

Maybe I'm defective myself, but the following strange thing happens
(tried with OpenDOS 7.01, DR-DOS 7.03 and MSDOS 6.22 command.com)

Code: Select all

C:\>set foo=bar
C:\>set
[...]
FOO=bar
C:\>echo %foo%
%foo%
C:\>


What the :evil:

Shouldn't I get "bar" on echo %foo% ?
Tried that on two different machines, even with plain DOS boot disk.

[edit: corrected typo]
Last edited by Voralyan on Mon Nov 18, 2013 12:37 pm, edited 1 time in total.
:A3502L: :O2000: :O200: = :O200: - :O200: :O200: :Octane: :Octane: :320: :O2: :Indigo2IMP: :Indy:
+ | d | i | g | i | t | a | l | +apple +[...] ;)

User avatar
kjaer
Posts: 433
Joined: Wed May 07, 2008 7:47 pm
Location: Seattle, WA
Contact:

Re: DOS environment variable expansion defective?

Unread postby kjaer » Mon Nov 18, 2013 10:10 am

Voralyan wrote:

Code: Select all

C:\>set foo=bar
C:\>set
[...]
FOO=bar
C:\>echo %foo%
%foo%
C:\>




um. what is the question here? that access to environment variables in DOS is case sensitive? I don't understand the problem.
:OnyxR: :IRIS3130: :IRIS2400: :Onyx: :ChallengeL: :4D220VGX: :Indigo: :Octane: :Cube: :Indigo2IMP: :Indigo2: :Indy:

User avatar
Voralyan
Posts: 142
Joined: Wed Mar 05, 2008 12:28 pm
Location: Osnabrück, Germany

Re: DOS environment variable expansion defective?

Unread postby Voralyan » Mon Nov 18, 2013 12:45 pm

On "echo %foo%" the value should be printed in the
next line and not the variable designator...

I tried the aforementioned example on WinNT's cmd.exe
and I get correctly "bar" as the output on "echo %foo%"...
But not on any DOS system running on two absolutely
different machines!

Maybe I'm overlooking something astonishing simple or
it's just the wrong pressure in the water pipes today... who knows?!

[edit: DOS is not case sensitive]
:A3502L: :O2000: :O200: = :O200: - :O200: :O200: :Octane: :Octane: :320: :O2: :Indigo2IMP: :Indy:
+ | d | i | g | i | t | a | l | +apple +[...] ;)

User avatar
Black Cardinal
Posts: 182
Joined: Fri Sep 25, 2009 10:40 am
Location: Albany, OR USA
Contact:

Re: DOS environment variable expansion defective?

Unread postby Black Cardinal » Mon Nov 18, 2013 2:09 pm

I have a vague recollection that the %foo% dereferencing only worked inside BAT files or in the environment passed to applications. I don't think it worked directly on the command line. I don't have a DOS system to try it out on nearby, though.
:Onyx2: 4x400MHz R12K Onyx2 IR3, 8GB RAM
:1600SW: :Indigo2IMP: R10K Indigo2 MaxIMPACT, 4 TRAMS, 768MB RAM, 2x9GB HD, CD-ROM, Phobos G160
Black Cardinal

tingo
Donor
Donor
Posts: 320
Joined: Sat Jun 26, 2010 5:40 pm
Location: Oslo, Norway

Re: DOS environment variable expansion defective?

Unread postby tingo » Mon Nov 18, 2013 3:03 pm

Try

Code: Select all

echo %%foo%%

Exercise for the reader: why is this required?
Torfinn

User avatar
porter
Posts: 2917
Joined: Wed Nov 01, 2006 10:37 pm
Location: NZ

Re: DOS environment variable expansion defective?

Unread postby porter » Mon Nov 18, 2013 3:58 pm

tingo wrote:Try

Code: Select all

echo %%foo%%

Exercise for the reader: why is this required?


Escapes me.
Land of the Long White Cloud and no Software Patents.

User avatar
hamei
Posts: 10437
Joined: Tue Feb 24, 2004 4:10 pm
Location: over the rainbow

Re: DOS environment variable expansion defective?

Unread postby hamei » Mon Nov 18, 2013 5:47 pm

porter wrote:Escapes me.

Shouldn't that be "Escapes me." ?
damn, bitch, you stupid fly ! let me pull up to your bumper and smack that monkey !

User avatar
porter
Posts: 2917
Joined: Wed Nov 01, 2006 10:37 pm
Location: NZ

Re: DOS environment variable expansion defective?

Unread postby porter » Tue Nov 19, 2013 12:07 pm

hamei wrote:
porter wrote:Escapes me.

Shouldn't that be "Escapes me." ?


Are you quoting me out of context?
Land of the Long White Cloud and no Software Patents.

User avatar
Voralyan
Posts: 142
Joined: Wed Mar 05, 2008 12:28 pm
Location: Osnabrück, Germany

Re: DOS environment variable expansion defective?

Unread postby Voralyan » Sun Nov 24, 2013 3:31 am

It's right, works only in batch files.
Have been working with WinNT's too long I think...
:A3502L: :O2000: :O200: = :O200: - :O200: :O200: :Octane: :Octane: :320: :O2: :Indigo2IMP: :Indy:
+ | d | i | g | i | t | a | l | +apple +[...] ;)


Return to “Miscellaneous Operating Systems/Hardware”

Who is online

Users browsing this forum: No registered users and 1 guest