Charles Dye
Super Moderator
- May
- 5,100
- 133
Staff member
Running a batch file which uses SETLOCAL / ENDLOCAL (i.e. most of them) erases the values of read-only environment variables. It does not, however, reset their read-only status.
I note in passing that child shells inherit the values of read-only environment variables, but not their read-only status. I infer that the list of protected variables is not stored in the environment, but somewhere else.
(Edit:) Above in TCC 16.02.48, 32-bit XP. Similar in TCC 15.01.58 and 14.03.59. I guess this is not a feature that anybody uses.
Code:
C:\>set /ro test=1
C:\>set test=2
C:\>set test
1
C:\>type wipeout.btm
@setlocal
@endlocal
C:\>wipeout
C:\>set test
TCC: Not in environment "test*"
C:\>set test=Something
C:\>set test
TCC: Not in environment "test*"
C:\>
I note in passing that child shells inherit the values of read-only environment variables, but not their read-only status. I infer that the list of protected variables is not stored in the environment, but somewhere else.
(Edit:) Above in TCC 16.02.48, 32-bit XP. Similar in TCC 15.01.58 and 14.03.59. I guess this is not a feature that anybody uses.