refactor(compat): replace [[ with [ ] for Bash 3.0+#610
Open
Chemaclass wants to merge 7 commits intomainfrom
Open
refactor(compat): replace [[ with [ ] for Bash 3.0+#610Chemaclass wants to merge 7 commits intomainfrom
Chemaclass wants to merge 7 commits intomainfrom
Conversation
Replace all ~410 [[ ]] test constructs across 28 source files with Bash 3.0+ compatible alternatives to ensure the framework works on macOS default bash and older systems. Replacements applied: - [[ ]] → [ ] for simple tests (-f, -n, -z, -eq, -gt, etc.) - [[ == ]] → [ = ] for string equality - [[ =~ ]] → grep -qE / sed extraction for regex matching - [[ == pattern* ]] → case statements for glob matching - Compound [[ A || B ]] → [ A ] || [ B ] - Compound [[ A && B ]] → [ A ] && [ B ]
Contributor
✅ Contributor ReportUser: @Chemaclass This user is on the trusted contributors list and was automatically approved. |
In Bash 3.0, `command -v` prints errors to stderr for missing commands unlike modern bash which is silent. Redirect stderr to /dev/null.
- Remove useless echo wrapping command -v output (SC2005)
- Quote variables in [ ] tests to prevent word splitting (SC2086)
- Suppress SC2001 for sed with backreferences (not replaceable by ${//})
- Replace inline `if case ... esac; then` patterns that may cause
parse errors in unpatched Bash 3.0.0 with separate case + if
- Consolidate multiple single-pattern case statements into one
- Fix shfmt formatting while preserving editorconfig line limits
bac86f7 to
eca6361
Compare
18cb87b to
e19ca2b
Compare
In unpatched Bash 3.0.0, `return` in a sourced file inside a for loop may not properly return from the source. Use if/else guard to prevent test function definitions when running under Bash 3.0. Also revert debug CI workflow changes.
e19ca2b to
0fffb35
Compare
The fixed filename temp_test_cases.txt caused race conditions when running tests in parallel mode, leading to "No such file or directory" errors when multiple subprocesses accessed the same file.
f46a3b9 to
0989925
Compare
Use explicit git -C $SANDBOX_DIR for all git operations instead of relying on cd, and add --allow-empty to ensure the initial commit always succeeds regardless of git version or configuration.
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
[[ ]]test constructs across 28 source files with Bash 3.0+ compatible alternatives[[ ]]→[ ]for simple tests,[ = ]for equality,grep -qE/sedfor regex,casefor glob matching[[ A || B ]]to[ A ] || [ B ]Test plan
[[test constructs remaining insrc/(only inside regex patterns/grep/sed)