carapace-sh / carapace

command argument completion generator for spf13/cobra
https://carapace.sh
Apache License 2.0
290 stars 8 forks source link

bash: file completion - additional tilde prefix added #944

Closed rsteube closed 7 months ago

rsteube commented 7 months ago

Current Behavior

Tab completing an open quoted path with tilde adds another one:

mv ~"/Downloads/with space<TAB>
# mv ~"~"/Downloads/with space" 

Expected Behavior

Not add another ~

Steps To Reproduce

No response

Version

0.45.0

OS

Shell

Anything else?

2023/12/02 20:59:36.723484 bash --------------------------------------------------------------------------------
2023/12/02 20:59:36.723536 bash []string{"carapace", "_carapace", "bash", "mv", "~/Downloads/w"}
2023/12/02 20:59:36.723622 bash COMPLINE "mv ~/Downloads/w"
2023/12/02 20:59:36.723656 bash patching args to []string{"bash", "mv", "~/Downloads/w"}
2023/12/02 20:59:36.723658 bash traverse called for "mv" with args []string{"~/Downloads/w"}
2023/12/02 20:59:36.723661 bash executing PreRun for "mv" with args []string{"~/Downloads/w"}
2023/12/02 20:59:36.723693 bash parsing flags for "mv" with args []string{}
2023/12/02 20:59:36.723696 bash completing positionals and subcommands for arg "~/Downloads/w"
false~"/Downloads/with space"
2023/12/02 20:59:42.023471 bash --------------------------------------------------------------------------------
2023/12/02 20:59:42.023531 bash []string{"carapace", "_carapace", "bash", "mv", "~/Downloads/with spac"}
2023/12/02 20:59:42.023632 bash COMPLINE "mv ~\"/Downloads/with spac"
2023/12/02 20:59:42.023666 bash patching args to []string{"bash", "mv", "~/Downloads/with spac"}
2023/12/02 20:59:42.023669 bash traverse called for "mv" with args []string{"~/Downloads/with spac"}
2023/12/02 20:59:42.023671 bash executing PreRun for "mv" with args []string{"~/Downloads/with spac"}
2023/12/02 20:59:42.023708 bash parsing flags for "mv" with args []string{}
2023/12/02 20:59:42.023710 bash completing positionals and subcommands for arg "~/Downloads/with spac"
false~"/Downloads/with space"

related https://github.com/rsteube/carapace/issues/947

rsteube commented 7 months ago

Should be an issue in carapace-shlex not correctly handling open quotes.

Looks like bash considers an open quote as wordbreak so anything before it won't be replaced.