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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions tasks/install_shell.sh
Original file line number Diff line number Diff line change
@@ -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.


# Install puppet-agent as a task
#
# From https://github.com/petems/puppet-install-shell/blob/master/install_puppet_5_agent.sh
Expand Down
2 changes: 2 additions & 0 deletions tasks/version_shell.sh
Original file line number Diff line number Diff line change
@@ -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 .

set -e

loc=/opt/puppetlabs/puppet/VERSION
if test -f $loc; then
echo "{\"version\":\"$(cat $loc)\",\"source\":\"${loc}\"}"
Expand Down
Loading