Skip to content

Changed ${,,} lowercase substitution towards a unix-universal tr#189

Open
FMenet-Dreeven wants to merge 1 commit intofrankbria:mainfrom
FMenet-Dreeven:fix/bash3-lowercase-compat
Open

Changed ${,,} lowercase substitution towards a unix-universal tr#189
FMenet-Dreeven wants to merge 1 commit intofrankbria:mainfrom
FMenet-Dreeven:fix/bash3-lowercase-compat

Conversation

@FMenet-Dreeven
Copy link

@FMenet-Dreeven FMenet-Dreeven commented Feb 19, 2026

Fix related to #187

Summary by CodeRabbit

  • Refactor
    • Technical improvements to internal script compatibility and handling.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 19, 2026

Walkthrough

Replaces 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

Cohort / File(s) Summary
Shell Compatibility Update
lib/wizard_utils.sh
Replaces ${var,,} parameter expansion with $(echo "$var" | tr '[:upper:]' '[:lower:]') for case-insensitive comparisons in default value handling and user input interpretation.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A rabbit hops through scripts so fine,
Bash expansions? Old design!
Now tr commands do the deed,
Portable shells will surely read.
Lowercase flows in every case,
Compatibility wins the race! 🎉

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: replacing Bash ${,,} parameter expansion with tr-based lowercasing for cross-shell compatibility.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@macroscopeapp
Copy link
Contributor

macroscopeapp bot commented Feb 19, 2026

Replace bash-specific lowercase expansion with tr for case-folding in confirm within wizard_utils.sh

Switch confirm to use echo | tr for lowercase normalization of the default label and user input in wizard_utils.sh.

📍Where to Start

Start at the confirm function in wizard_utils.sh.


Macroscope summarized a5ce2df.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
lib/wizard_utils.sh (1)

39-39: Portable tr-based lowercasing is correct — consider printf over echo for 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: echo in Bash interprets leading flags like -n (suppresses newline) or -e (enables escapes). If $default or $response ever starts with a -, echo might mangle the output. For $default this is practically impossible given the documented "y"/"n" contract; for $response (free-form read) 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:]')" in

Also 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.

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.

1 participant

Comments