ros_gz
ros_gz copied to clipboard
shim package executables fail when passed argument contains whitespace
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
- Create a xacro file
test.xacrowith contents:
<!-- test.xacro -->
<?xml version="1.0" ?>
<robot name="test"/>
- 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().