Fzf: -bash: _fzf_orig_completion_g++: bad substitution

Created on 24 Sep 2016  路  6Comments  路  Source: junegunn/fzf

  • Category

    • [ ] fzf binary

    • [ ] fzf-tmux script

    • [ ] Key bindings

    • [x] Completion

    • [ ] Vim

    • [ ] Neovim

    • [ ] Etc.

  • OS

    • [ ] Linux

    • [x] Mac OS X

    • [ ] Windows

    • [ ] Etc.

  • Shell

    • [x] bash

    • [ ] zsh

    • [ ] fish

I am on the latest master 7fa5e6c. On a fresh terminal, I type emacsclient ~/a and press tab. Then -bash: _fzf_orig_completion_g++: bad substitution will be displayed, giving this terminal screen:

$ emacsclient ~/a-bash: _fzf_orig_completion_g++: bad substitution

[a list of filenames that start with an `a` inside my home dir; elided]

At this point if I press tab again, then the normal completion will continue and this error will not happen a second time in the same shell session.

I believe it has to do with lines 280 and 281 of completion.bash:

  orig_var="_fzf_orig_completion_$cmd"
  orig="${!orig_var}"

According to the bash 4 manual (I am on 4.4.0(1)-release), a name is:

A word consisting only of alphanumeric characters and underscores, and beginning with an alphabetic character or an underscore.

I guess that means _fzf_orig_completion_g++ is indeed not a name?

Most helpful comment

If, like me, you are using Cygwin, arrive here from a search for the error, and have no real memory or clue how/when fzf became part of your installation and where its files reside, I found the necessary file to apply the above changes to in /etc/bash_completion.d/zzz-fzf. I don't know if the name will be the same for you, but it was the only fzf-named file in the directory on my system.

All 6 comments

Hi, thanks for the report. Can you check if this patch helps?

diff --git a/shell/completion.bash b/shell/completion.bash
index 9436e27..36c25af 100644
--- a/shell/completion.bash
+++ b/shell/completion.bash
@@ -277,7 +277,7 @@ _fzf_defc() {
   cmd="$1"
   func="$2"
   opts="$3"
-  orig_var="_fzf_orig_completion_$cmd"
+  orig_var="_fzf_orig_completion_${cmd//+/_}"
   orig="${!orig_var}"
   if [ -n "$orig" ]; then
     printf -v def "$orig" "$func"

Same issue with my bash.

Error Prints:

-bash: _fzf_orig_completion_g++: bad substitution

Bash Version:

$ bash --version
GNU bash, version 4.4.5(1)-release (i686-pc-cygwin)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

FZF version

$ fzf --version
fzf 0.8.9 (Dec 24, 2014)

@j5shi The support for Cygwin was discontinued since 0.9.0 due to the portability issue of ncurses library. But I'm working on a new renderer that does not depend on ncurses (#782), and it might be possible that we can make the latest fzf work on Cygwin again (#794). I'll let you know if it works out.

Sounds exciting! Thanks!

Had same issue (on Cygwin) with xdg-open.
Here's what I have now that fixes it:

  cmd="$1"
  func="$2"
  opts="$3"
  cmd="${cmd//+/_}"
  cmd="${cmd//-/_}"
  orig_var="_fzf_orig_completion_$cmd"

There probably would be other possible situations like this, this should be made more robust, with all special chars replaced with something (preferrably something unique).

If, like me, you are using Cygwin, arrive here from a search for the error, and have no real memory or clue how/when fzf became part of your installation and where its files reside, I found the necessary file to apply the above changes to in /etc/bash_completion.d/zzz-fzf. I don't know if the name will be the same for you, but it was the only fzf-named file in the directory on my system.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jan-warchol picture jan-warchol  路  3Comments

ahmedelgabri picture ahmedelgabri  路  3Comments

jberglinds picture jberglinds  路  3Comments

fenuks picture fenuks  路  3Comments

chrisamow picture chrisamow  路  3Comments