Make icp.sh POSIX-compatible (dash/sh safe) - #614
Conversation
📝 WalkthroughWalkthroughThe launcher script 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@distribution/scripts/icp.sh`:
- Line 1: The script uses the bash-only keyword "local" which breaks POSIX
/bin/sh; remove each "local" declaration and replace it with a plain assignment
(e.g., myvar="value") or, if you need scoping, run the code in a subshell or
prefix variables with a unique name (e.g., _myvar) to avoid collisions; update
every occurrence of "local" in the script so functions and assignments (the
places where local was used) use POSIX-compatible assignments instead.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c316131b-ca70-4926-a730-8b4971db6ebc
📒 Files selected for processing (1)
distribution/scripts/icp.sh
| @@ -1,4 +1,4 @@ | |||
| #!/bin/bash | |||
| #!/bin/sh | |||
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Read-only check for non-POSIX `local` declarations in the launcher.
# This should list every line that still needs to be rewritten for sh compatibility.
rg -n '\blocal\b' distribution/scripts/icp.shRepository: wso2/integration-control-plane
Length of output: 161
🏁 Script executed:
# Check the shebang on line 1
head -1 distribution/scripts/icp.sh
# Read the file to see the full context of local declarations
cat -n distribution/scripts/icp.sh | head -100Repository: wso2/integration-control-plane
Length of output: 3776
Remove local declarations to match POSIX sh shebang.
The shebang changed to /bin/sh, but the code still uses the bash-specific local keyword at lines 37, 47, 67, and 78. These declarations will fail in POSIX-compliant sh environments (e.g., dash), preventing the script from running. Replace local declarations with unscoped variable assignment or use alternative approaches compatible with POSIX sh.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@distribution/scripts/icp.sh` at line 1, The script uses the bash-only keyword
"local" which breaks POSIX /bin/sh; remove each "local" declaration and replace
it with a plain assignment (e.g., myvar="value") or, if you need scoping, run
the code in a subshell or prefix variables with a unique name (e.g., _myvar) to
avoid collisions; update every occurrence of "local" in the script so functions
and assignments (the places where local was used) use POSIX-compatible
assignments instead.
The WSO2 Integrator extension invokes this script via `sh icp.sh`
(not `bash icp.sh`), so on Ubuntu where /bin/sh is dash, bash-only
syntax breaks:
- `JAVA_OPTS=()` — bash array init
- `JAVA_OPTS+=(...)` — bash array append
- `"${JAVA_OPTS[@]}"` — bash array expansion
Replace with plain string variable. When JAVA_OPTS is empty, the
unquoted $JAVA_OPTS expands to nothing (no empty arg passed to java).
Verified: `dash -n icp.sh` passes.
ef1b177 to
d029ec4
Compare
Problem
The WSO2 Integrator extension launches
icp.shvia:On Ubuntu/Debian,
/bin/shisdash. The shebang (#!/bin/bash) is ignored since the extension invokes the script explicitly withsh. The script uses bash-only array syntax thatdashcannot parse:JAVA_OPTS=()— bash array initializationJAVA_OPTS+=()— bash array append"${JAVA_OPTS[@]}"— bash array expansiondashfails with a hard syntax error at parse time:This prevents ICP from starting when launched from the extension on Ubuntu/Debian.
It works on macOS and Fedora/RHEL because
/bin/shisbashon those platforms:/bin/shFix
Replace bash arrays with a plain string variable — the only construct that
dashcannot handle. The shebang stays as#!/bin/bash(the script useslocaland may add other bash features in the future).When
JAVA_OPTSis empty, the unquoted$JAVA_OPTSexpands to nothing (no spurious empty argument passed tojava).Verified:
dash -n icp.shpasses.