Commit graph

9 commits

Author SHA1 Message Date
Johannes Altmanninger
6b5ad163d3 Fix double expansion of tokenized command line
Commit 798527d79a (completions: fix double evaluation of tokenized
commandline, 2024-01-06) fixed some completions such as the "watchexec"
ones by adding "string escape" here:

	set argv (commandline -opc | string escape) (commandline -ct)

This fixed double evaluation when we later call `complete -C"$argv"`.

Unfortunately -- searching for "complete -C" and
"__fish_complete_subcommand" -- it seems like that commit missed some
completions such as sudo.  Fix them the same way.

Alternatively, we could defer expansion of those arguments (via
--tokens-raw), since the recursive call to completion will expand
them anyway, and we don't really need to know their value.

But there are (contrived) examples where we do want to expand first,
to correctly figure out where the subcommand starts:

	sudo {-u,someuser} make ins

By definition, the tokens returned by `commandline -opc` do not
contain the token at cursor (which we're currently completing).
So the expansion should not hurt us. There is an edge case where
cartesian product expansion would produce too many results, and we
pass on the unexpanded input. In that case the extra escaping is very
unlikely to have negative effects.

Fixes # 11041
Closes # 11067

Co-authored-by: kerty <g.kabakov@inbox.ru>
2025-01-19 18:29:07 +01:00
Johannes Altmanninger
29f35d6cdf completion: adopt commandline -x replacing deprecated -o
This gives us more accurate completions because completion scripts get
expanded paths
2024-01-27 09:28:06 +01:00
David Adam
45fb2024f8 completions: drop shebang from non-executable files
These completion files do not get marked as executable, so they don't
need a shebang.
2020-02-18 21:34:19 +08:00
Akatsuki
cb72a33e0c Fix some issues in __fish_complete_subcommand.fish
Fix 'string length: Unknown option': add `--` before $subcommand

Fix count $subcommand always = 1 with `sudo` and `doas`:
give argv as array to __fish_complete_subcommand

[ci skip]
2019-11-17 00:39:06 +01:00
Johannes Altmanninger
4f1fa9513c Make most subcommand completions take external commands only
Also fix ssh completions which were broken by
277fca9c6a.
2019-11-05 11:47:05 +01:00
Johannes Altmanninger
36693e4391 Complete empty subcomands consistently
If the command is empty, try to complete starting from the empty command
instead of the whole commandline.
2019-11-05 09:05:46 +01:00
Johannes Altmanninger
dfc1d1931d Add /usr/local/sbin to PATH for sudo completions
[ci skip]
2019-11-01 17:20:09 +01:00
Johannes Altmanninger
e0d4a1d78b Fix sudo/doas completions not using /sbin
Fixes #6259
[ci skip]
2019-11-01 21:24:03 +08:00
Digital
794b448c00 Add completions for openbsd's doas (#5196)
* Add completions for openbsd's doas

* Update CHANGELOG.md

* Implement requested changes
2018-09-25 12:31:46 +02:00