Skip to content

Fix exit command in console interactive mode#2086

Merged
ollevche merged 1 commit into
opentofu:mainfrom
boaz0:fix_exit_in_console_interactive_mode
Oct 29, 2024
Merged

Fix exit command in console interactive mode#2086
ollevche merged 1 commit into
opentofu:mainfrom
boaz0:fix_exit_in_console_interactive_mode

Conversation

@boaz0
Copy link
Copy Markdown
Contributor

@boaz0 boaz0 commented Oct 19, 2024

When typing "exit" the code does run "break" but since "switch" is the innermost statement and not "for", the program is still running and not exiting with status code 0.

To fix it, "return 0" when "exit" is typed instead of "break".

Resolves #

Target Release

1.9.0

Checklist

  • I have read the contribution guide.
  • I have not used an AI coding assistant to create this PR.
  • I have written all code in this PR myself OR I have marked all code I have not written myself (including modified code, e.g. copied from other places and then modified) with a comment indicating where it came from.
  • I (and other contributors to this PR) have not looked at the Terraform source code while implementing this PR.

Go checklist

  • I have run golangci-lint on my change and receive no errors relevant to my code.
  • I have run existing tests to ensure my code doesn't break anything.
  • I have added tests for all relevant use cases of my code, and those tests are passing.
  • I have only exported functions, variables and structs that should be used from other packages.
  • I have added meaningful comments to all exported functions, variables, and structs.

Website/documentation checklist

  • I have locally started the website as described here and checked my changes.

@boaz0 boaz0 requested a review from a team as a code owner October 19, 2024 22:28
@github-actions
Copy link
Copy Markdown

Reminder for the PR assignee: If this is a user-visible change, please update the changelog as part of the PR.

@ghost
Copy link
Copy Markdown

ghost commented Oct 20, 2024

Hi and thank you for the Pull Request. The core team regularly reviews PRs, but this can take a little time. Please bear with us while we get to your review. If you're interested, the contribution guide has an FAQ with some info on PRs. In the meantime can you work through the checklist in the description and make sure you’ve completed each of the tasks?

cam72cam
cam72cam previously approved these changes Oct 21, 2024
Comment thread internal/command/console_interactive.go Outdated
@boaz0
Copy link
Copy Markdown
Contributor Author

boaz0 commented Oct 22, 2024

@ollevche - i hope i addressed all your concerns. I ran unit tests to make sure nothing is broken and did play around to make sure the behavior is not broken.

@boaz0 boaz0 requested review from cam72cam and ollevche October 22, 2024 10:54
@boaz0 boaz0 force-pushed the fix_exit_in_console_interactive_mode branch 3 times, most recently from 9b6631a to 5454a6f Compare October 22, 2024 11:50
Copy link
Copy Markdown
Contributor

@ollevche ollevche left a comment

Choose a reason for hiding this comment

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

Hey @boaz0 thanks for the update! I think we shouldn't make any additional changes besides replacing switch-case with if-else. Sorry for not making it clear beforehand!

@boaz0 boaz0 force-pushed the fix_exit_in_console_interactive_mode branch from 5454a6f to e610453 Compare October 22, 2024 13:02
@boaz0
Copy link
Copy Markdown
Contributor Author

boaz0 commented Oct 22, 2024

no worries @ollevche
I apologize for the misunderstanding on my part as well 😺

@boaz0 boaz0 requested a review from ollevche October 22, 2024 13:05
Comment thread internal/command/console_interactive.go Outdated
@boaz0 boaz0 force-pushed the fix_exit_in_console_interactive_mode branch from e610453 to c1f4188 Compare October 24, 2024 17:39
When typing "exit" the code does run "break" but since
"switch" is the innermost statement and not "for",
the program is still running and not exiting with status code 0.

To fix it, "if-else" is used instead of "switch-case".

Signed-off-by: Boaz Shuster <boaz.shuster.github@gmail.com>
@boaz0 boaz0 force-pushed the fix_exit_in_console_interactive_mode branch from c1f4188 to a636f73 Compare October 24, 2024 17:57
@boaz0 boaz0 requested a review from ollevche October 24, 2024 17:57
Copy link
Copy Markdown
Contributor

@ollevche ollevche left a comment

Choose a reason for hiding this comment

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

Thank you for the fix, @boaz0!

@ollevche ollevche merged commit 810df00 into opentofu:main Oct 29, 2024
@ollevche
Copy link
Copy Markdown
Contributor

We forgot to update changelog file for this PR and some of the others. I opened a separate PR for this: #2116

@boaz0 boaz0 deleted the fix_exit_in_console_interactive_mode branch October 30, 2024 07:03
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.

3 participants