- SET allows spaces in variable name. Edit: For example: set name =value includes trailing space in the variable name
New discoveries for me:
- SET strips leading spaces from variable names.
- Other leading token delimiters like comma and semicolon are not stripped.
- Using SET to list variable definitions is odd when name starts with token delimiter like colon or semicolon.
Code: Select all
@echo on
@setlocal
set test
set " test=leading spaces"
set " test 2 =leading, middle, and trailing spaces"
set ",test=leading comma"
set ";test=leading semicolon"
set test
set ,test
set ;test
set ,|findstr /b ", ;"
set ;|findstr /b ", ;"
@echo ----------------------------------------------------
@echo %% test%%=% test%
@echo %% test 2 %%=% test 2 %
@echo %%test%%=%test%
@echo %%test 2 %%=%test 2 %
@echo %%,test%%=%,test%
@echo %%;test%%=%;test%
Code: Select all
D:\test>set test
Environment variable test not defined
D:\test>set " test=leading spaces"
D:\test>set " test 2 =leading, middle, and trailing spaces"
D:\test>set ",test=leading comma"
D:\test>set ";test=leading semicolon"
D:\test>set test
test=leading spaces
test 2 =leading, middle, and trailing spaces
D:\test>set ,test
test=leading spaces
test 2 =leading, middle, and trailing spaces
D:\test>set ;test
test=leading spaces
test 2 =leading, middle, and trailing spaces
D:\test>set , | findstr /b ", ;"
,test=leading comma
;test=leading semicolon
D:\test>set ; | findstr /b ", ;"
,test=leading comma
;test=leading semicolon
----------------------------------------------------
% test%=
% test 2 %=
%test%=leading spaces
%test 2 %=leading, middle, and trailing spaces
%,test%=leading comma
%;test%=leading semicolon
Dave Benham