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

job.sh: fix ERR trap #2218

Merged

Conversation

matthewrmshin
Copy link
Contributor

Turn on set -e so that if cmd1 fails in a cmd1; cmd2 syntax, the
failure is trapped.

Turn on `set -e` so that if `cmd1` fails in a `cmd1; cmd2` syntax, the
failure is trapped.
@matthewrmshin matthewrmshin added this to the next release milestone Mar 28, 2017
@matthewrmshin matthewrmshin self-assigned this Mar 28, 2017
@hjoliver
Copy link
Member

(It affected commands on separate lines too I think - I just used semicolons to save space in describing the problem)

Copy link
Member

@oliver-sanders oliver-sanders left a comment

Choose a reason for hiding this comment

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

false | true now causes task failure.

@matthewrmshin
Copy link
Contributor Author

false | true (false pipe to true) should cause failure - due to set -o pipefail.

false || true (false or true) should continue to work, however.

Copy link
Member

@oliver-sanders oliver-sanders left a comment

Choose a reason for hiding this comment

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

OK, good.

@hjoliver
Copy link
Member

hjoliver commented Mar 28, 2017

For the record, on master this does not get trapped either (i.e. the single-line semi-colon construct isn't relevant - so I'll change the issue title slightly):

[runtime]
   [[foo]]
       script = """
true
false
true"""

@hjoliver hjoliver changed the title job.sh: fix ERR trap in semicolon commands job.sh: fix ERR trap in script items Mar 28, 2017
@hjoliver
Copy link
Member

Actually, on master even an error in an environment var definition will not be trapped.

@hjoliver hjoliver changed the title job.sh: fix ERR trap in script items job.sh: fix ERR trap Mar 28, 2017
Copy link
Member

@hjoliver hjoliver left a comment

Choose a reason for hiding this comment

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

Tested as fixed - thanks.

@hjoliver hjoliver merged commit f4dc2b9 into cylc:master Mar 28, 2017
@matthewrmshin matthewrmshin deleted the fix-jobscript-semicolon-err-trap branch March 28, 2017 20:42
@matthewrmshin
Copy link
Contributor Author

A bit surprised by that. How did scripts that were expected to fail worked in the test battery? Do we by chance only have command failure at the end of functions?

@hjoliver
Copy link
Member

I guess so! I've just made a new test that confirms this (passes here, fails on master). I'll put up a PR.

@hjoliver hjoliver mentioned this pull request Mar 28, 2017
matthewrmshin added a commit to matthewrmshin/rose that referenced this pull request Mar 29, 2017
Jobs now die with EXIT instead of ERR.
matthewrmshin added a commit to matthewrmshin/rose that referenced this pull request Mar 30, 2017
Jobs now die with EXIT instead of ERR.
oliver-sanders added a commit to metomi/rose that referenced this pull request Mar 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants