Skip to content

Add a composable string-strip substitution - #997

Merged
ahcorde merged 1 commit into
ros2:rollingfrom
Dylan-Gallagher:fix/string-strip-substitution
Aug 25, 2026
Merged

Add a composable string-strip substitution#997
ahcorde merged 1 commit into
ros2:rollingfrom
Dylan-Gallagher:fix/string-strip-substitution

Conversation

@Dylan-Gallagher

Copy link
Copy Markdown
Contributor

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

@peci1 peci1 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, you're reading my mind! I just needed this last week :-D

I looked at the PR and it looks good!

@ahcorde

ahcorde commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Pulls: #997
Gist: https://gist.githubusercontent.com/ahcorde/98a6d0846d0a02d94eaa07dea0e6afe3/raw/ae805cbbb23ba00ea93b998b037f21e2e5ca8714/ros2.repos
BUILD args: --packages-above-and-dependencies launch launch_xml launch_yaml
TEST args: --packages-above launch launch_xml launch_yaml
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/20189

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

@peci1

peci1 commented Aug 24, 2026

Copy link
Copy Markdown

Wow, you're reading my mind!

Nope, you're reading my issues, I figured :)

I've used your PR as a seed for my agent to produce IsEmpty and NotEmpty: #998 . It worked flawlessly =)

@ahcorde
ahcorde merged commit 183b1c5 into ros2:rolling Aug 25, 2026
3 checks passed
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)

3 participants