I've found an issue when executing:
Code: Select all
Z:\>SET TEST= test
Z:\>SET TEST_A= test a
Z:\>safeTrim TEST
Z:\>SET TEST
TEST=test a
TEST_A= test a
Code: Select all
@echo off
setlocal enableDelayedExpansion
set x=%1
if not defined x exit /b 1
for /f "tokens=1* delims==" %%a in (
'set %1'
) do (
set call _TMP=%%x:%%a=%%
if not defined _TMP endlocal & call :exec %%b
)
goto :EOF
:exec
set %x%=%*
goto :EOF
Or just make one little change to line 4
≡≡≡≡≡begin c:\Cmd\test\safetrim.cmd≡≡≡≡≡
1. @echo off
2. set x=%1
3. for /f "tokens=1* delims==" %%a in (
4. 'set %1 ^|findstr /b /i /c:"%1="'
5. ) do call :exec %%b
6. goto :EOF
7. :exec
8. set %x%=%*
9. goto :EOF
≡≡≡≡≡end c:\Cmd\test\safetrim.cmd≡≡≡≡≡
Phil Robyn