fix: shell script robustness in setup-config.sh#24
Open
AI-Reviewer-QS wants to merge 1 commit intotetherto:mainfrom
Open
fix: shell script robustness in setup-config.sh#24AI-Reviewer-QS wants to merge 1 commit intotetherto:mainfrom
AI-Reviewer-QS wants to merge 1 commit intotetherto:mainfrom
Conversation
Fix multiple shell scripting issues: - Use `find -print0 | while read -d ''` instead of word-splitting on `find` output, preventing breakage on filenames with spaces - Escape dot in sed regex: `s/.example//` -> `s/\.example$//` to match only literal `.example` suffix, not any char before `example` - Remove `break` from arg parsing case so all arguments are processed instead of silently dropping args after `-t` - Quote all variable expansions in dirname/basename calls - Remove duplicate `status` entry in .gitignore
878e402 to
90f3501
Compare
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
setup-config.shthat could cause incorrect behavior with non-trivial filenames or argument combinationsstatusentry in.gitignoreChanges
1. Safe file iteration (line 12)
Before:
for file in $(find config -type f -name "*.example")After:
find config -type f -name "*.example" -print0 | while IFS= read -r -d '' fileWord-splitting on
findoutput breaks on filenames with spaces. Using-print0/read -d ''handles all filenames safely.2. Escaped dot in sed regex (line 13)
Before:
sed -E -e 's/.example//'After:
sed -E -e 's/\.example$//'The unescaped
.matches any character (e.g.,Xexample), not just a literal dot. Also anchored to$to only strip the trailing suffix.3. Argument parsing fix (line 7)
Before:
-t | --test ) include_test=true; break ;;After:
-t | --test ) include_test=true ;;The
breakexits thewhileloop entirely, silently dropping any arguments after-t. Removing it lets all arguments be processed.4. Quoted variable expansions (lines 18-19)
Before:
dirname $new_name/basename $new_nameAfter:
dirname "$new_name"/basename "$new_name"5. Duplicate .gitignore entry
Removed duplicate
statuson line 14 (already present on line 10).Test plan
./setup-config.shproduces correct output (verified)./setup-config.sh -tproduces correct test config files (verified)bash -n setup-config.shpasses syntax check