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.
https://bugzilla.redhat.com/show_bug.cgi?id=541423#c3
Done by adding the eval back. The only thing that this breaks AFAIK
is handling of known hosts filenames that have more than one
consecutive space in them, but I couldn't figure out how to get both
to work and IMO support for files starting with ~ is much more
important.
https://bugzilla.redhat.com/show_bug.cgi?id=541423#c2
As a side effect, this simplifies things somewhat and grabs user and
global known hosts filenames from config files with one command
instead of doing one for each.
Moved making-expected-list-unique out of `match_items()' & `get_hosts()'
into `assert_complete()' because the former are low level functions and
items need not necessarily be unique. They only need to be unique when
we're actually testing *completions*.