Skip to content

Add a composable string-strip substitution - #997

Open
Dylan-Gallagher wants to merge 1 commit into
ros2:rollingfrom
Dylan-Gallagher:fix/string-strip-substitution
Open

Add a composable string-strip substitution#997
Dylan-Gallagher wants to merge 1 commit into
ros2:rollingfrom
Dylan-Gallagher:fix/string-strip-substitution

Conversation

@Dylan-Gallagher

Copy link
Copy Markdown

Description

Add a composable StringStripSubstitution, exposed to XML and YAML frontends as $(string-strip ...).

This lets a newline-terminated command result be stripped before it is composed with another substitution:

<let name="hostname" value="$(string-strip $(command 'hostname'))"/>

Command itself is unchanged and continues to return raw stdout, including trailing newlines. string-strip is opt-in and also composes with launch configurations, environment variables, and other string-valued substitutions.

Fixes #995.

Is this user-facing behavior change?

Yes. Python launch descriptions can use StringStripSubstitution(value), and XML/YAML launch descriptions can use $(string-strip value). The substitution applies Python's str.strip() semantics, removing leading and trailing whitespace without escaping or otherwise transforming the value.

Testing

  • 287 core launch functional tests passed.
  • 29 launch_xml functional tests passed.
  • 17 launch_yaml functional tests passed.
  • The exact command -> strip -> eval XML composition was exercised successfully.
  • Changed Python files pass Flake8; new files pass ament_copyright; compilation and diff checks pass.

Did you use Generative AI?

OpenAI Codex (GPT-5) assisted with the implementation, tests, and documentation in this change. I reviewed the complete diff, reproduced the reported failure, and ran the validation listed above.

Additional Information

Stripping resolves the trailing-newline failure reported in #995. It does not make arbitrary command output safe to interpolate as Python source; quotes and backslashes still require context-appropriate handling.

Signed-off-by: Dylan Gallagher <76841713+Dylan-Gallagher@users.noreply.github.com>
@mergify

mergify Bot commented Aug 17, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Impossible to use the result of $(command) inside $(eval)

1 participant