ros2 / ros2/launch

Empty string in ExecuteProcess command should be ignored

Open
#638 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement help wanted
Dominant language
Python
Stars
155
Forks
182
Avg merge
2d 14h
Merged PRs (30d)
6

Description

Feature request

Feature description

When passing a command to ExecuteProcess, it would be nice if empty strings were filtered out and not passed to the executable.
For example,

# Executes: "ls foo '' bar"
ExecuteProcess(cmd=['ls', 'foo', '', 'bar'])

It would be better, IMO, if the empty string was not passed to the process, and we got the output of ls foo bar instead of ls foo '' bar.

This came up in the following scenario where we want to construct the command list at runtime via substitutions (like LaunchConfiguration):

import launch
from launch.actions import DeclareLaunchArgument
from launch.actions import ExecuteProcess
from launch.substitutions import LaunchConfiguration


def generate_launch_description():
    command = ['./count_args.sh', 'foo', LaunchConfiguration('bar')]
    return launch.LaunchDescription([
        DeclareLaunchArgument('bar', default_value=''),
        ExecuteProcess(cmd=command, output='screen'),
    ])

In the above example, LaunchConfiguration may result in an empty string, in which case we want to ignore it.

Implementation considerations

Since it is plausible that there are use-cases for passing empty strings, we should make sure this is still possible.
We could achieve this by allowing users to pass a pair of nested quotes, e.g.

ExecuteProcess(cmd=['echo', 'foo', "''", 'bar'])

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the ExecuteProcess implementation and trace how command entries, including LaunchConfiguration substitutions, are resolved before being passed to the executable. Define and test the behavior for empty substitutions while preserving an explicit way to pass an empty argument, using the examples in the issue as the completion criteria.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.