Fix bug for crontab feature when user's cron table is empty#690
Merged
gsketefian merged 2 commits intoMar 4, 2022
Conversation
1) Fix calls to "printf" command by including the "%s" formatting string. Otherwise, if the user's cron table is empty, the crontab_contents variable is undefined and causes scripts to crash. 2) Use "printf" instead of "echo" in manipulating crontab contents because "echo" adds a newline at the end of its output even if the variable to be printed out is empty.
…e; otherwise, the crontab command will fail on Cheyenne. Also, indent comments for consistency.
gsketefian
commented
Mar 4, 2022
| # | ||
| printf -v ${outvarname_crontab_cmd} "${__crontab_cmd__}" | ||
| printf -v ${outvarname_crontab_contents} "${__crontab_contents__}" | ||
| printf -v ${outvarname_crontab_cmd} "%s" "${__crontab_cmd__}" |
Collaborator
Author
There was a problem hiding this comment.
These printf -v commands contain the original bug found by @chan-hoo.
Collaborator
Author
|
@chan-hoo Can you test again on Hera as well as on WCOSS_DELL_P3? Thanks. |
Collaborator
|
@gsketefian, it worked well on Hera as well as on the wcoss dell. |
chan-hoo
approved these changes
Mar 4, 2022
christinaholtNOAA
approved these changes
Mar 4, 2022
Contributor
christinaholtNOAA
left a comment
There was a problem hiding this comment.
This looks pretty straightforward.
Collaborator
Author
|
@chan-hoo @christinaholtNOAA Thanks for reviewing. Merging now. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DESCRIPTION OF CHANGES:
When a user's
crontable is empty, theget_crontab_contentsfunction does not set the return variable properly due to a bug in the wayprintf -v ...is called towards the end of that function. This PR fixes that bug as well as some others found after testing with an initially empty user cron table.TESTS CONDUCTED:
On Hera, Jet, and Cheyenne, ran the WE2E test
deactivate_tasks, starting with both an emptycrontable and a non-empty one. All tests passed with thecrontable being modified properly at the start and end of the test.CONTRIBUTORS (optional):
@chan-hoo pointed out this error on Hera.