Skip to content

Fix AWS CLI installation logic in check_awscli()#22

Open
Aeagon07 wants to merge 1 commit into
LondheShubham153:mainfrom
Aeagon07:main
Open

Fix AWS CLI installation logic in check_awscli()#22
Aeagon07 wants to merge 1 commit into
LondheShubham153:mainfrom
Aeagon07:main

Conversation

@Aeagon07

@Aeagon07 Aeagon07 commented Jun 10, 2026

Copy link
Copy Markdown

Issue

The check_awscli() function used exit 1 when AWS CLI was not installed.

Since the function is invoked as:

check_awscli || install_awscli

calling exit 1 terminates the entire script before install_awscli() can be executed.

Fix

Replaced:

exit 1

with:

return 1

This allows the function to return a failure status to the caller while preserving the intended control flow.

Why not return 0?

In shell scripting, a return value of 0 indicates success.

If check_awscli() returns 0 when AWS CLI is not installed, the shell interprets the check as successful and the right-hand side of:

check_awscli || install_awscli

will never execute.

Returning 1 correctly indicates failure and triggers install_awscli() through the || operator.

Result

  • AWS CLI installed: execution continues normally.
  • AWS CLI not installed: install_awscli() is executed.
  • The script proceeds with the remaining workflow after installation.

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR modifies day03/create_ec2.sh to improve error handling and argument passing. The check_awscli function now returns a non-zero status instead of exiting the script, enabling fallback logic to attempt installation. The script entrypoint forwards command-line arguments to main.

Changes

Script control flow improvements

Layer / File(s) Summary
Error handling fallback and argument forwarding
day03/create_ec2.sh
check_awscli changes from exit 1 to return 1, allowing the calling context to execute install_awscli as a fallback. The script's entrypoint calls main "$@" to pass command-line arguments through to main.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A script now flows with grace divine,
When AWS CLI is not aligned,
No harsh exit stops the way,
It returns to try install—hooray!
Arguments pass through, loud and clear.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and concisely describes the main change: fixing the AWS CLI installation logic in the check_awscli() function by switching from exit 1 to return 1.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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