Changed ${,,} lowercase substitution towards a unix-universal tr#189
Changed ${,,} lowercase substitution towards a unix-universal tr#189FMenet-Dreeven wants to merge 1 commit intofrankbria:mainfrom
Conversation
WalkthroughReplaces Bash parameter expansion syntax for lowercasing with portable tr command equivalents in two locations within the wizard utilities script. This preserves existing behavior while improving shell compatibility for case-insensitive value comparisons. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Replace bash-specific lowercase expansion with
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
lib/wizard_utils.sh (1)
39-39: Portabletr-based lowercasing is correct — considerprintfoverechofor robustness.The replacement of
${var,,}with$(echo "$var" | tr '[:upper:]' '[:lower:]')is functionally equivalent and resolves the Bash 4.0+ requirement, which is the right fix for macOS/Bash 3.x compatibility.One minor edge case:
echoin Bash interprets leading flags like-n(suppresses newline) or-e(enables escapes). If$defaultor$responseever starts with a-,echomight mangle the output. For$defaultthis is practically impossible given the documented "y"/"n" contract; for$response(free-formread) it has a safe fallback (the*branch re-prompts). Still,printf '%s\n'is unconditionally safe and equally portable:♻️ Proposed hardening with
printf- if [[ "$(echo "$default" | tr '[:upper:]' '[:lower:]')" == "y" ]]; then + if [[ "$(printf '%s\n' "$default" | tr '[:upper:]' '[:lower:]')" == "y" ]]; then- case "$(echo "$response" | tr '[:upper:]' '[:lower:]')" in + case "$(printf '%s\n' "$response" | tr '[:upper:]' '[:lower:]')" inAlso applies to: 53-53
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/wizard_utils.sh` at line 39, Replace use of echo in the lowercase checks with printf to avoid echo interpreting leading flags: change occurrences like "$(echo "$default" | tr '[:upper:]' '[:lower:]')" (and the similar "$(echo "$response" | tr '[:upper:]' '[:lower:]')" at the other check) to use printf '%s\n' so the lowercasing remains portable and safe on macOS/Bash 3.x while preserving the tr transformation; update both instances found in lib/wizard_utils.sh.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@lib/wizard_utils.sh`:
- Line 39: Replace use of echo in the lowercase checks with printf to avoid echo
interpreting leading flags: change occurrences like "$(echo "$default" | tr
'[:upper:]' '[:lower:]')" (and the similar "$(echo "$response" | tr '[:upper:]'
'[:lower:]')" at the other check) to use printf '%s\n' so the lowercasing
remains portable and safe on macOS/Bash 3.x while preserving the tr
transformation; update both instances found in lib/wizard_utils.sh.
Fix related to #187
Summary by CodeRabbit