Skip to content

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

@dluc

Description

@dluc

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions