From: KJK::Hyperion <no...@li...> - 2002-07-05 23:50:25
|
At 00.25 06/07/2002, you wrote: > > Sorry, but I think the bug is in the ReactOS shell. It should > > ExpandEnvironmentStrings() the command line >The ReactOS shell (shell.exe) doesn't support environment variables at all. >The problem was that the expansion of environment variables works on >Windows when cmd is used. Although cmd doesn't call >ExpandEnvironmentStrings(). SetEnvironmentVariable() expands environment >variables but ReactOS didn't implement that. has this been verified? because here (Windows 2000 Professional) I'm able to set a variable to "%PATH%" without it being expanded: ALDEBARAN\Hyperion [D:\home\Hyperion] ::set DOH=^%PATH^% ALDEBARAN\Hyperion [D:\home\Hyperion] ::echo %DOH% %PATH% I've written a proof-of-concept in Delphi: (************************************************************) program envtest; {$APPTYPE CONSOLE} uses Windows ; var env: PChar; begin (* set a variable to a value containing a reference to another variable *) SetEnvironmentVariable('DOH', '%PATH%'); (* get a pointer to the environment *) env:= GetEnvironmentStrings(); (* repeat until the environment is empty *) while env^ <> #0 do begin (* print the current variable *) WriteLn(String(env)); (* skip until the null terminator *) repeat Inc(env); until env^ = #0; (* skip the null terminator *) Inc(env); end; end. (************************************************************) It outputs: =::=::\ ALLUSERSPROFILE=D:\home\shared APPDATA=D:\home\Hyperion\Dati applicazioni BASEDIR=D:\devtools\ntddk BCCDIR=D:\devtools\bcc CLASSPATH=D:\programmi\sviluppo\sdk\Java\jre\lib;D:\programmi\sviluppo\sdk\Java\lib;.;"D:\Programmi\JavaSoft\JRE\1.3\lib\ext\QTJava.zip" CommonProgramFiles=D:\Programmi\File comuni COMPUTERNAME=ALDEBARAN ComSpec=D:\WINNT\system32\cmd.exe DDKDRIVE=D: DOH=%PATH% [<--- ] [and more] It looks like SetEnvironmentVariable doesn't parse the variable's value in any way (except scanning for the null terminator, of course). Maybe RtlSetEnvironmentVariable does? Let's see: (************************************************************) program envtest2; {$APPTYPE CONSOLE} type NTSTATUS = Cardinal; BOOLEAN = LongBool; PWSTR = PWideChar; USHORT = Word; UNICODE_STRING = record Length, MaximumLength: USHORT; Buffer: PWSTR; end; procedure RtlInitUnicodeString( var DestinationString: UNICODE_STRING; const SourceString: PWSTR ); stdcall; external 'ntdll.dll'; function RtlCreateEnvironment( Inherit: BOOLEAN; var Environment: PWSTR ): NTSTATUS; stdcall; external 'ntdll.dll'; procedure RtlDestroyEnvironment( Environment: PWSTR ); stdcall; external 'ntdll.dll'; function RtlSetEnvironmentVariable ( var Environment: PWSTR; var Name, Value: UNICODE_STRING ): NTSTATUS; stdcall; external 'ntdll.dll'; var environ, envtail: PWSTR; dohName, dohValue: UNICODE_STRING; begin (* copy the environment *) RtlCreateEnvironment(True, environ); RtlInitUnicodeString(dohName, 'DOH'); RtlInitUnicodeString(dohValue, '%PATH%'); (* set DOH="%PATH%" *) RtlSetEnvironmentVariable(environ, dohName, dohValue); envtail:= environ; (* repeat until the environment is empty *) while envtail^ <> #0 do begin (* write the current variable *) WriteLn(String(envtail)); (* skip until the null terminator *) repeat Inc(envtail) until envtail^ = #0; (* skip the null terminator *) Inc(envtail); end; (* destroy the copy of the environment *) RtlDestroyEnvironment(environ); end. (************************************************************) and here's the output: =::=::\ ALLUSERSPROFILE=D:\home\shared APPDATA=D:\home\Hyperion\Dati applicazioni BASEDIR=D:\devtools\ntddk BCCDIR=D:\devtools\bcc CLASSPATH=D:\programmi\sviluppo\sdk\Java\jre\lib;D:\programmi\sviluppo\sdk\Java\lib;.;"D:\Programmi\JavaSoft\JRE\1.3\lib\ext\QTJava.zip" CommonProgramFiles=D:\Programmi\File comuni COMPUTERNAME=ALDEBARAN ComSpec=D:\WINNT\system32\cmd.exe DDKDRIVE=D: DOH=%PATH% [<--- ] [and more] Nope. Windows doesn't expand variable references, unless explicitely asked for. ReactOS shouldn't either |