test: Expected a combining operator like '-a' at index 4
joehillen opened this issue · 6 comments
Describe the bug
Getting this error:
test: Expected a combining operator like '-a' at index 4 = files _fifc_source_files _fifc_comp_2 _fifc_comp_3 _fifc_comp_4 _fifc_comp_5 _fifc_comp_6 _fifc_comp_7 _fifc_comp_8[1]
^
~/.config/fish/functions/_fifc_action.fish (line 1):
in function '_fifc_action' with arguments 'source'
called on line 1 of file ~/.config/fish/functions/_fifc.fish
in command substitution
called on line 25 of file ~/.config/fish/functions/_fifc.fish
This happens right before fzf launches, by pressing ctrl-x
.
The stack trace isn't exactly helpful. Any ideas? What is it trying to do? I can probably figure it out myself if you can give me a tip.
Hi @joehillen!
What was the command you were typing?
Did you add any custom completion rules?
Completion rules are stored in lists and are tested against the command you are typing.
As _fifc_action
is called with source
arg, the test
call may come from the command evaluated here:
fifc/functions/_fifc_action.fish
Line 58 in adff596
This evaluated command (defined in completion rule) should retrieve a list of completion suitable for the current context, and the error you see happens when evaluating that particular command.
Strangely, I can reproduce but only when using WSL, it works fine on Linux distros
I'm using arch 6.0.7-arch1-1 and it shows me the error
I am not sure why it is happening, but for me this came about when using fish within tmux and not within an xterm. So, it seemed like it was a double initialisation issue. The other reason to make me think this is that when I experience the error various _fifc_comp_
variables had duplicated content. So the way I fixed it for me was to delete the _fifc_comp_
variable before setting it. I did this with the following diff:
diff --git a/functions/fifc.fish b/functions/fifc.fish
index f7c5910..3f81edb 100644
--- a/functions/fifc.fish
+++ b/functions/fifc.fish
@@ -38,6 +38,8 @@ function fifc -d "Add your own fish fzf completions"
set _fifc_comp_count (math $_fifc_comp_count + 1)
set -l count $_fifc_comp_count
+ set -e -U "_fifc_comp_$count"
+ set -e -g "_fifc_comp_$count"
set -Ux "_fifc_comp_$count"
set -a "_fifc_comp_$count" "$_flag_n"
set -a "_fifc_comp_$count" "$_flag_r"
Without the fix I would get:
_fifc_comp_10=test "$fifc_group" = processes ps -ax -o pid=,command= test "$fifc_group" = processes ps -ax -o pid=,command=
With the fix:
_fifc_comp_10=test "$fifc_group" = processes ps -ax -o pid=,command=
Which is at least valid syntax. I am not sure this completely resolves all the issues with the _fifc_comp_*
variables. Because when in tmux I still get a bunch of duplicates:
> env | sort | grep _fifc | grep "processes\s*ps -ax"
_fifc_comp_10=test "$fifc_group" = processes ps -ax -o pid=,command=
_fifc_comp_18=test "$fifc_group" = processes ps -ax -o pid=,command=
_fifc_comp_26=test "$fifc_group" = processes ps -ax -o pid=,command=
_fifc_comp_2=test "$fifc_group" = processes ps -ax -o pid=,command=
_fifc_comp_34=test "$fifc_group" = processes ps -ax -o pid=,command=
I suspect the fifc function needs to also check whether there is already a variable with the matching "body" and only add new ones. But my above hack did enough to solve the issue for me.
Good catch @timcleaver! Should be gone on main now, that fixed for me too ;) Fixed on main