Skip to content

Commit

Permalink
#467: quickfix for tilde expansion (#468)
Browse files Browse the repository at this point in the history
  • Loading branch information
hohwille authored Sep 24, 2020
1 parent 251afef commit d3847cb
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions scripts/src/main/resources/scripts/environment-project.bat
Original file line number Diff line number Diff line change
Expand Up @@ -84,29 +84,25 @@ set "line=%*"
if "%~1%" == "export" (
rem remove export as this only makes sense on linux/mac
set line=!line:~7!
if "%~3%" == "" (
set "search=%~2%"
) else (
set "search=%~2% "
)
set "replacement=%~2%="
shift
)
if "%~2%" == "" (
set "search=%~1"
) else (
if "%~2%" == "" (
set "search=%~1%"
) else (
set "search=%~1% "
)
set "replacement=%~1%="
set "search=%~1 "
)
set "replacement=%~1="
set value=%~2
if "!value:~0,1!" == "~" (
rem variable value starts with tilde that needs to be replaced with users home dir (USERPROFILE)
set line=%replacement%%USERPROFILE%!value:~1!
) else (
set line=!line:%search%=%replacement%!
)
set line=!line:%search%=%replacement%!
rem replace ${var} variable syntax with windows %var% syntax
set line=!line:${=%%!
set line=!line:}=%%!
set line=!line:"=%!
rem resolve ~ to user home (USERPROFILE)
if "!value:~0,1!" == "~" (
set "value=%USERPROFILE%!value:~1!"
)
set line=!line:"=!
(
rem endlocal in () block to access local variable and "export" it
endlocal
Expand Down

0 comments on commit d3847cb

Please sign in to comment.