Skip to content
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

[bash] user input should be replaced by the suggested command #90

Open
dluc opened this issue May 16, 2022 · 4 comments
Open

[bash] user input should be replaced by the suggested command #90

dluc opened this issue May 16, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@dluc
Copy link
Collaborator

dluc commented May 16, 2022

In bash (I haven't checked other shells, so it might be happening in other environments) when pressing ctrl-g the plugin automatically searches and suggests a command to run, without replacing the original text.

If the original text doesn't start with #, ie it's not a comment, when the user hits enter, the shell executes both the NL sentence and the suggested command, leading to unexpected errors and potential issues.

Example 1: expected user interaction:

  1. Enter # what's the temperature in Oslo?
  2. Press ctrl-g
  3. Codex suggests curl wttr.in/Oslo
  4. User hits Enter
  5. Shell executes the suggested command without errors

Example 2: unexpected user interaction:

  1. Enter what's the temperature in Oslo?
  2. Press ctrl-g
  3. Codex suggests curl wttr.in/Oslo
  4. User hits Enter
  5. The shell hangs waiting for the user to enter a single quote, and eventually throws an error

(note in this picture # is my shell prompt, not part of the input)
image

This happens because the original text is not replaced, so the shell executes both the user initial input and the suggested command. This could lead to very unexpected results depending on what the user sentence contains.

@dluc
Copy link
Collaborator Author

dluc commented May 18, 2022

perhaps when putting the original text back, the code could add a # prefix if missing

@ryanvolum
Copy link
Contributor

perhaps when putting the original text back, the code could add a # prefix if missing

This is an interesting idea. The project currently does assume that the user will always model their input as a comment. That said, I'm sure many people will do what you did above - injecting a comment operator would make sense in that case.

@codehruv, what do you think of doing this?

@codehruv
Copy link
Contributor

this would simplify the experience so it would be great to try. I can try and see if I can accomplish this with the tooling in powershell

@DevAtDawn
Copy link

@dluc @ryanvolum @codehruv made a pull request, needs to be tested/reviewed lmk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants