Skip to content

sh tasks: Run with set -e #711

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

Merged
merged 1 commit into from
Sep 25, 2024
Merged

sh tasks: Run with set -e #711

merged 1 commit into from
Sep 25, 2024

Conversation

bastelfreak
Copy link
Collaborator

This ensures that the task doesn't continue when an error happened. This is also best practice in bash.

This ensures that the task doesn't continue when an error happened. This
is also best practice in bash.
@bastelfreak bastelfreak requested a review from a team as a code owner April 10, 2024 13:09
@@ -1,4 +1,7 @@
#!/usr/bin/env bash

set -e
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be tested a bit, I don't know if this works out of the box on all operating systems

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set is a bash builtin, so assuming the script is executed with Bash (as the shebang requires), then it should work fine.
ref: https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That wasn't my point. I don't know if the whole code is compatible with -e.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either the code does proper error checking, either the test suite needs some fixes 🤷

From my point of view, the best test case is to release it to the public and if this cause trouble, fix the trouble.

Copy link
Contributor

@kenyon kenyon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pasted these into https://www.shellcheck.net/ and didn't see any findings related to error exits. Lots of other findings in install_shell.sh though.

Copy link
Contributor

@smortex smortex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for good practice!

@joshcooper
Copy link
Contributor

I'm running this through our supported platforms to see if anything breaks.

@joshcooper joshcooper added the bug Something isn't working label Sep 24, 2024
Copy link
Contributor

@joshcooper joshcooper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests passed in https://jenkins-platform.delivery.puppetlabs.net/view/puppet-agent/view/puppetlabs-puppet_agent%20module/view/ad-hoc/job/forge-module_puppetlabs-puppet-agent-module_intn-sys_pa-acceptance_7-nightly_to_8-nightly-adhoc/46/ except some newer platforms failed to install due to using an older beaker 3.0.x I think it's because this PR was created before we updated our modulesync dependencies.

@joshcooper joshcooper merged commit 5d8cbe7 into puppetlabs:main Sep 25, 2024
17 checks passed
@mhashizume mhashizume mentioned this pull request Sep 25, 2024
@@ -1,5 +1,7 @@
#!/bin/sh

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shebang does not require bash here, so open to interpretation (default /bin/sh is dash on Ubuntu), @bastelfreak .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants