Improve shell script safety and error handling#126
Open
shbhmexe wants to merge 2 commits intocncf:masterfrom
Open
Improve shell script safety and error handling#126shbhmexe wants to merge 2 commits intocncf:masterfrom
shbhmexe wants to merge 2 commits intocncf:masterfrom
Conversation
Enhanced quoting, error handling, and strict mode in backup_artificial.sh, db_data_mv.sh, sort_json.sh, and grafana_start.sh. These changes prevent accidental data loss, improve robustness, and ensure safer file operations. Added a new empty file XcwSsn. Signed-off-by: shbhmexe <shubhushukla586@gmail.com>
Signed-off-by: Shubham shukla <shubhushukla586@gmail.com>
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.
Summary
This PR delivers two focused, low-risk fixes that improve safety and correctness of shell scripts without changing any features:
set -euo pipefail).cp -a -v --to preserve attributes and robustly copy data.rm -rfand path arguments (--) to prevent accidental deletions when variables are empty or contain spaces.rm -f -- "$f"/*rm -rf -- "$f"$fpoints to a valid directory.--, quotes) to avoid unintended deletions and path issues.Reasoning and impact
Files changed