Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix topic_tools environment hook #1486

Merged
merged 1 commit into from
Aug 27, 2018

Conversation

mintar
Copy link
Contributor

@mintar mintar commented Aug 14, 2018

Without this commit, source /opt/ros/$ROS_DISTRO/setup.bash fails under the following conditions:

  1. topic_tools is installed

  2. rosbash is not installed

  3. the bash shell has the following options set (which is the default in GitLab CI):

    set -o errexit
    set -o pipefail

What happens is that since rosbash is not installed, $(complete | grep -w rosrun) finds no match, and grep exits with status 1. Since pipefail is enabled, this error code is propagated to the return value of the pipe. Since errexit is enabled, the script exits immediately.

This commit catches grep exit status 1 (= "no match") and passes everything else through.

Supersedes #1484.

Without this commit, `source /opt/ros/$ROS_DISTRO/setup.bash` fails under the following conditions:

1. topic_tools is installed
2. rosbash is not installed
3. the bash shell has the following options set (which is the default in GitLab CI):

    set -o errexit
    set -o pipefail

What happens is that since rosbash is not installed, `$(complete | grep -w rosrun)` finds no match, and grep exits with status 1. Since `pipefail` is enabled, this error code is propagated to the return value of the pipe. Since `errexit` is enabled, the script exits immediately.

This commit catches grep exit status 1 (= "no match") and passes everything else through.
@mintar
Copy link
Contributor Author

mintar commented Aug 14, 2018

I've verified that the bug exists in melodic + kinetic, and that this PR fixes it:

https://gitlab.com/mintar/ros_comm/-/jobs/89166959

https://gitlab.com/mintar/ros_comm/blob/ci/.gitlab-ci.yml

This PR should also be backported to kinetic and lunar.

@mintar
Copy link
Contributor Author

mintar commented Aug 14, 2018

BTW: I had a hell of a time figuring out what the problem exactly was and why I could reproduce it in GitLab CI, but not locally, before I thought of the shell options. Now I can reproduce it reliably both in GitLab CI and locally.

@dirk-thomas
Copy link
Member

Thank you for the patch.

@dirk-thomas dirk-thomas merged commit 1e41c8f into ros:melodic-devel Aug 27, 2018
@mintar
Copy link
Contributor Author

mintar commented Aug 30, 2018

@dirk-thomas Thanks for merging! Could you please also backport this patch to kinetic + lunar?

@mintar mintar deleted the topic_tools_rosbash2 branch August 30, 2018 14:42
@dirk-thomas
Copy link
Member

👍 After it has been released into Melodic it will be consider for backporting.

dirk-thomas pushed a commit that referenced this pull request Aug 3, 2020
Without this commit, `source /opt/ros/$ROS_DISTRO/setup.bash` fails under the following conditions:

1. topic_tools is installed
2. rosbash is not installed
3. the bash shell has the following options set (which is the default in GitLab CI):

    set -o errexit
    set -o pipefail

What happens is that since rosbash is not installed, `$(complete | grep -w rosrun)` finds no match, and grep exits with status 1. Since `pipefail` is enabled, this error code is propagated to the return value of the pipe. Since `errexit` is enabled, the script exits immediately.

This commit catches grep exit status 1 (= "no match") and passes everything else through.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants