Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add missing quote around set arguments in bat #111

Merged
merged 1 commit into from
Dec 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions ament_package/template/prefix_level/_local_setup_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ def main(argv=sys.argv[1:]): # noqa: D103
FORMAT_STR_USE_ENV_VAR = '%{name}%'
FORMAT_STR_INVOKE_SCRIPT = \
'call:_ament_prefix_bat_call_script "{script_path}"'
FORMAT_STR_REMOVE_TRAILING_SEPARATOR = 'if "%{name}:~-1%==";" ' \
'set {name}=%{name}:~0,-1%'
# can't use `if` here since each line is being `call`-ed
FORMAT_STR_REMOVE_TRAILING_SEPARATOR = \
'call:_ament_prefix_bat_strip_trailing_semicolon "{name}"'
else:
assert False, 'Unknown primary extension: ' + args.primary_extension

Expand Down
14 changes: 14 additions & 0 deletions ament_package/template/prefix_level/local_setup.bat.in
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,17 @@ goto:eof
echo not found: "%~1" 1>&2
)
goto:eof


:: strip a trailing semicolon from an environment variable if applicable
:: first argument: the environment variable name
:_ament_prefix_bat_strip_trailing_semicolon
setlocal enabledelayedexpansion
set "name=%~1"
set "value=!%name%!"
if "%value:~-1%"==";" set "value=%value:~0,-1%"
:: set result variable in parent scope
endlocal & (
set "%~1=%value%"
)
goto:eof