ros_gz icon indicating copy to clipboard operation
ros_gz copied to clipboard

shim package executables fail when passed argument contains whitespace

Open ijnek opened this issue 3 years ago • 0 comments

Environment

  • OS Version: Ubuntu 22.04
  • ROS Version: Humble
  • Source or binary build? Source, latest humble branch

Description

Calling shim executables with arguments that contain white spaces encapsulated in double quotes fails on ROS 2 Humble.

  • Expected behavior: ros_ign_gazebo and ros_gz_sim's create displays same behaviour, apart from the deprecation message.

  • Actual behavior: Calling ros_gz_sim's create works, but calling ros_ign_gazebo's create results in an error.

Steps to reproduce

  1. Create a xacro file test.xacro with contents:
<!-- test.xacro -->
<?xml version="1.0" ?>
<robot name="test"/>
  1. Run ros_ign_gazebo create with an argument that evaluates to have a space within double quotes:
ros2 run ros_ign_gazebo create -string "$(xacro test.xacro)"

Output

Results in the following error:

sh: 2: Syntax error: newline unexpected

Speculation

The shim packages in this repo takes char * argv[], concatenate them into a string separate by whitespace, then calls system() using it. If argv contains an argument that contains a whitespace, that argument will be broken up into multiple arguments when calling system().

ijnek avatar Nov 05 '22 10:11 ijnek