Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[bash] Refactor access to "_fzf_orig_complete_${cmd//[^A-Za-z0-9_]/_}"
In the current codebase, for the original completion settings, the pieces of the codes to determine the variable name and to access the stored data are scattered. In this patch, we define functions to access these variables. Those functions will be used in a coming patch. * This patch also resolves an inconsistent escaping of "$cmd": $cmd is escaped as ${...//[^A-Za-z0-9_]/_} in some places, but it is escaped as ${...//[^A-Za-z0-9_=]/_} in some other places. The latter leaves the character "=" in the command name, which causes an issue because "=" cannot be a part of a variable name. For example, the following test case produces an error message: $ COMP_WORDBREAKS=${COMP_WORDBREAKS//=} $ _test1() { COMPREPLY=(); } $ complete -vF _test1 cmd.v=1.0 $ _fzf_setup_completion path cmd.v=1.0 $ cmd.v=1.0 [TAB] bash: _fzf_orig_completion_cmd_v=1_0: invalid variable name The behavior of leaving "=" was present from the beginning when saving the original completion is introduced in commit 9140151, and this does not seem to be a specific reasoning. In this patch, we replace "=" as well as the other non-identifier characters. * Note: In this patch, the variable REPLY is used to return values from functions. This design is to make it useful with the value substitutions, a new Bash feature of the next release 5.3, which is taken from mksh.
- Loading branch information