The COMP_ settings of the last test of _count_args() were falling through to
the first test of _get_cword(), causing it to fail.
Unset COMP_ variables within the unit tests setup & teardown.
Fixed last test at `_count_args.exp' by solving conflicting settings of
COMP_CWORD and COMP_POINT.
Steps to reproduce the problem:
$ ./runUnit _count_args.exp _get_cword.exp
...
Running ./unit/_count_args.exp ...
Running ./unit/_get_cword.exp ...
ERROR Unexpected output from bash command "_get_cword should run without errors":
bash: $index: substring expression < 0
...
If a word is made up of multiple word separator characters:
$ a b::<TAB> # CWORDS are: a, b, and :: (correct)
__reassemble_comp_words_by_ref() couldn't handle this. It assumed CWORDS were:
$ a b::<TAB> # CWORDS: a, b, : and : (but they're not)
Added test case for this. To run the automated tests:
./runUnit _get_cword.exp
The solution for bash-4 is to remove the colon from COMP_WORDBREAKS:
COMP_WORDBREAKS=${COMP_WORDBREAKS//:}
The workaround for bash-3, or bash-4 with a colon in COMP_WORDBREAKS,
is to call:
__ltrim_colon_completions "$cur"
after completions have been put in COMPREPLY.
See also: E13) Why does filename completion misbehave if a colon appears
in the filename? - Bash FAQ, http://tiswww.case.edu/php/chet/bash/FAQ
Actually enhanced __get_cword3 to _get_cword, and removed __get_cword4.
__get_cword4 could handle chars to exclude from COMP_WORDBREAKS, but
failed with partial quoted arguments (e.g. "a 'b c|", | = cursor
position). This was no problem till bash-4.0.35, because bash < 4.0.35
also returned partial quoted arguments incorrectly. See also:
http://www.mail-archive.com/bug-bash@gnu.org/msg06094.html
Now that bash-4.0.35 returns quoted arguments ok, __get_cword3 is
enhanced to also handle chars to exclude from COMP_WORDBREAKS. Because
__get_cword3 also handles partial quoted arguments correctly, this makes
__get_cword3 suitable for bash-4 as well.
Code in `unit_start()' and `completion_start()' is merged and put central in
lib/library.exp:
- start_bash()
- source_bash_completion()
- init_tcl_bash_globals()
Global string variable `bash_versinfo_0' is replaced with list variable
`BASH_VERSINFO'.
Completing directories after `screen -c' passes on bash-4 now that
_filedir does a `compopt -o filenames'.
The test yields an expected failure on bash-3.
Expands only tilde (~), if first char, in variable.
This function displays bash's capabilities of passing a variable by
reference (variable indirection) which allows us to avoid using a
subshell. As far as I can see it works surprisingly well?
To run the automated test:
./runUnit __expand_tilde_by_ref.exp
Also fixed some testsuite issues regarding list splitting.
The testsuite failed on _known_hosts_real on bash-3. After long searching, it
appears that on bash-3 (not bash-4) array expansion with a modified IFS causes
the array to merge into a single item (!). See also:
http://www.mail-archive.com/bug-bash@gnu.org/msg06520.html
The effect was that multiple UserKnownHostsFiles in one config file weren't
detected properly.
The faulting parameter expansion ("${tmpkh[@]//\"/}) actually isn't necessary
anymore, since eval is done now, so it is removed.