Skip to content

Confirmation prompt not working on Windows #347

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
JohnRusk opened this issue Aug 18, 2020 · 10 comments · Fixed by #413
Closed

Confirmation prompt not working on Windows #347

JohnRusk opened this issue Aug 18, 2020 · 10 comments · Fixed by #413
Labels
component/cli Command Line Interface kind/bug Something isn't working

Comments

@JohnRusk
Copy link

Here's an example (running from Windows Powershell)

>tk apply environments/default
Applying to namespace <REDACTED>
Please type 'yes' to confirm: yes
aborted by user

Notice that when I type "yes", tk replies with "aborted by user".

A (temporary) workaround is to add the --dangerous-auto-approve flag. (I like the name, by the way!)

@issue-label-bot issue-label-bot bot added the kind/bug Something isn't working label Aug 18, 2020
@issue-label-bot
Copy link

Issue-Label Bot is automatically applying the label kind/bug to this issue, with a confidence of 0.96. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

@sh0rez
Copy link
Member

sh0rez commented Aug 18, 2020

This is probably related to this code:

tanka/pkg/term/alert.go

Lines 16 to 23 in 931373a

read, err := reader.ReadString('\n')
if err != nil {
return errors.Wrap(err, "reading from stdin")
}
if read != approval+"\n" {
return errors.New("aborted by user")
}
return nil

Probably the different line endings on Windows are the problem. It would need \r\n.

However, it seems like there is no os constant in Go for this?!

@JohnRusk
Copy link
Author

Yeah, I don't think there is a constant. But this would presumably work:

if strings.Trim(read, "\r\n") != approval {   // trim all EOL chars from read, instead of adding any to approval
    return ....

@sh0rez
Copy link
Member

sh0rez commented Aug 18, 2020

Good idea! Wanna try that out and if it works, create a PR?

@JohnRusk
Copy link
Author

Will do.

@sh0rez sh0rez added the component/cli Command Line Interface label Aug 20, 2020
@stale
Copy link

stale bot commented Sep 19, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Sep 19, 2020
@JohnRusk
Copy link
Author

Thanks for the reminder, StaleBot. I'm struggling to find time for this. May or may not get to it. Sorry about that sh0rez.

@stale stale bot removed the stale label Sep 20, 2020
@stale
Copy link

stale bot commented Oct 21, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Oct 21, 2020
@stale stale bot closed this as completed Oct 28, 2020
@nlowe
Copy link
Contributor

nlowe commented Oct 28, 2020

This is still a problem in the most recent release and should be re-opened.

nlowe added a commit to nlowe/tanka that referenced this issue Oct 28, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
This fixes confirmation promts on windows by scanning for a line of
input and comparing that to the desired prompt. term.Confirm(...) is
refactored slightly to make it easier to test.

Fixes grafana#347
nlowe added a commit to nlowe/tanka that referenced this issue Oct 28, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
This fixes confirmation prompts on windows by scanning for a line of
input and comparing that to the desired prompt. term.Confirm(...) is
refactored slightly to make it easier to test.

Fixes grafana#347
@sh0rez sh0rez reopened this Oct 28, 2020
@stale stale bot removed the stale label Oct 28, 2020
sh0rez pushed a commit that referenced this issue Nov 24, 2020
This fixes confirmation prompts on windows by scanning for a line of
input and comparing that to the desired prompt. term.Confirm(...) is
refactored slightly to make it easier to test.

Fixes #347
@JohnRusk
Copy link
Author

Nice @sh0rez . Sorry I never got time to attempt doing this for you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/cli Command Line Interface kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants