carapace-sh/carapace

bash: redirects are passed to completion function

rsteube opened this issue · 0 comments

Current Behavior

Duh! Seems redirects are actually passed to the completion function in bash so this needs to be handled as well.

Expected Behavior

File completion for redirects

Steps To Reproduce

echo test >[TAB]   # attached
echo test > [TAB]  # next arg
echo test <[TAB]   # attached
echo test < [TAB]  # next arg
echo test 1>[TAB]  # stdout
echo test 2>[TAB]  # stderr
echo test <>[TAB]  # both attached
echo test <> [TAB] # both next

Version

0.42.0

OS

  • Linux
  • OSX
  • Windows

Shell

  • Bash
  • Elvish
  • Fish
  • Nushell
  • Oil
  • Powershell
  • Xonsh
  • Zsh

Anything else?

Prefix can be assumed for a quick solution but carapace-shlex
should be used to parse COMP_LINE to see that the redirect isn't quoted.
(Actually seems COMP_WORDS would also be an option, but for shlex needs to be able handle this for Split anyway)

see https://www.gnu.org/software/bash/manual/html_node/Redirections.html