Skip to content

support command chaining for --flash-cmd#153

Merged
bennyz merged 1 commit into
centos-automotive-suite:mainfrom
bennyz:wrap-flash-cmd
Mar 12, 2026
Merged

support command chaining for --flash-cmd#153
bennyz merged 1 commit into
centos-automotive-suite:mainfrom
bennyz:wrap-flash-cmd

Conversation

@bennyz

@bennyz bennyz commented Mar 12, 2026

Copy link
Copy Markdown
Contributor

So users can do --flash-cmd "j power cycle && j storage flash ..."

Summary by CodeRabbit

  • Bug Fixes
    • Improved image flashing command execution reliability in shell environments.

Signed-off-by: Benny Zlotnik <bzlotnik@redhat.com>
@coderabbitai

coderabbitai Bot commented Mar 12, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This pull request modifies the flash_image.sh script to wrap the FLASH_CMD execution with sh -c, changing how the command is invoked under the JMP shell. The modification affects both the OCI credentials and no-credentials execution paths, with error handling logic remaining unchanged.

Changes

Cohort / File(s) Summary
Shell script command execution
internal/common/tasks/scripts/flash_image.sh
Wrapped FLASH_CMD invocation with sh -c "${FLASH_CMD}" in two locations to ensure proper shell parsing and expansion of the command string.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • bkhizgiy

Poem

🐰 A shell script hops with newfound grace,
sh -c now guides each command's pace,
Where FLASH_CMD danced without a shell,
Now properly parsed—all works well!

🚥 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 'support command chaining for --flash-cmd' clearly summarizes the main change: enabling shell command chaining in the --flash-cmd option by wrapping the command execution with sh -c.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan for PR comments
  • Generate coding plan

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
internal/common/tasks/scripts/flash_image.sh (1)

81-92: ⚠️ Potential issue | 🟠 Major

Preserve fail-fast semantics for chained flash commands.

Plain sh -c returns the status of the last command in the snippet, so a value like cmd1; cmd2 can make this task succeed even when the actual flash step failed earlier. If the contract is "allow chaining, but fail on the first unexpected error," use -e in both branches.

Suggested change
         OCI_USERNAME="${OCI_USERNAME}" \
         OCI_PASSWORD="${OCI_PASSWORD}" \
-        sh -c "${FLASH_CMD}"
+        sh -ec "${FLASH_CMD}"
         FLASH_EXIT=$?
         set -e  # Restore errexit
 else
     # No credentials, run flash command directly
     # shellcheck disable=SC2086
     set +e  # Temporarily disable errexit to capture exit code
-    jmp shell ${JMP_SHELL_ARGS} -- sh -c "${FLASH_CMD}"
+    jmp shell ${JMP_SHELL_ARGS} -- sh -ec "${FLASH_CMD}"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/common/tasks/scripts/flash_image.sh` around lines 81 - 92, The flash
sequence can hide earlier failures because plain sh -c returns the last
command's status; modify both jmp shell invocations that run "${FLASH_CMD}" so
the shell runs with the -e (errexit) option (e.g. sh -e -c "${FLASH_CMD}" or
prefix the command with "set -e; ${FLASH_CMD}") to make the chain fail fast,
while still capturing the exit code into FLASH_EXIT and preserving the
surrounding set +e / set -e behavior and use of JMP_SHELL_ARGS,
OCI_USERNAME/OCI_PASSWORD and FLASH_CMD.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@internal/common/tasks/scripts/flash_image.sh`:
- Around line 81-92: The flash sequence can hide earlier failures because plain
sh -c returns the last command's status; modify both jmp shell invocations that
run "${FLASH_CMD}" so the shell runs with the -e (errexit) option (e.g. sh -e -c
"${FLASH_CMD}" or prefix the command with "set -e; ${FLASH_CMD}") to make the
chain fail fast, while still capturing the exit code into FLASH_EXIT and
preserving the surrounding set +e / set -e behavior and use of JMP_SHELL_ARGS,
OCI_USERNAME/OCI_PASSWORD and FLASH_CMD.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6434bea9-fe2d-4d73-ae59-a446ec22a358

📥 Commits

Reviewing files that changed from the base of the PR and between 51ce0ec and 82f83f8.

📒 Files selected for processing (1)
  • internal/common/tasks/scripts/flash_image.sh

@bennyz bennyz requested a review from bkhizgiy March 12, 2026 18:02
@bennyz bennyz merged commit abecc4c into centos-automotive-suite:main Mar 12, 2026
4 checks passed
@bennyz bennyz deleted the wrap-flash-cmd branch March 12, 2026 18:50
@coderabbitai coderabbitai Bot mentioned this pull request Apr 29, 2026
10 tasks
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