Skip to content

fix: shell script robustness in setup-config.sh#24

Open
AI-Reviewer-QS wants to merge 1 commit intotetherto:mainfrom
AI-Reviewer-QS:fix/setup-config-shell-bugs
Open

fix: shell script robustness in setup-config.sh#24
AI-Reviewer-QS wants to merge 1 commit intotetherto:mainfrom
AI-Reviewer-QS:fix/setup-config-shell-bugs

Conversation

@AI-Reviewer-QS
Copy link

Summary

  • Fix multiple shell scripting bugs in setup-config.sh that could cause incorrect behavior with non-trivial filenames or argument combinations
  • Remove duplicate status entry in .gitignore

Changes

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 '' file

Word-splitting on find output 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 break exits the while loop 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_name
After: dirname "$new_name" / basename "$new_name"

5. Duplicate .gitignore entry

Removed duplicate status on line 14 (already present on line 10).

Test plan

  • ./setup-config.sh produces correct output (verified)
  • ./setup-config.sh -t produces correct test config files (verified)
  • bash -n setup-config.sh passes syntax check
  • Existing unit and integration tests pass

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
@AI-Reviewer-QS AI-Reviewer-QS force-pushed the fix/setup-config-shell-bugs branch from 878e402 to 90f3501 Compare February 14, 2026 01:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants