Add a composable string-strip substitution - #997
Conversation
Signed-off-by: Dylan Gallagher <76841713+Dylan-Gallagher@users.noreply.github.com>
|
Tick the box to add this pull request to the merge queue (same as
|
peci1
left a comment
There was a problem hiding this comment.
Wow, you're reading my mind! I just needed this last week :-D
I looked at the PR and it looks good!
|
Pulls: #997 |
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 =) |
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:
Commanditself is unchanged and continues to return raw stdout, including trailing newlines.string-stripis 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'sstr.strip()semantics, removing leading and trailing whitespace without escaping or otherwise transforming the value.Testing
launchfunctional tests passed.launch_xmlfunctional tests passed.launch_yamlfunctional tests passed.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.