This fixes completing filenames containing single quote (') on bash-4.
Also added emulation of `-o filenames' to _filedir.
Added tests for _filedir.
Fixed array assignment within __reassemble_comp_words_by_ref().
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
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.
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.
This fixes the auto tests for `finger' and `ssh' on machines where an IPv6 host
"::1" is mentioned in /etc/hosts.
Added helper function __ltrim_colon_completions.
To run the tests:
./runCompletion finger.exp ssh.exp
Changed the last `echo' to a `printf' to make completing `-n' or '-e'
come through. Declaring a function local (break_index & word_start)
also doesn't work on my machine: the functions become visible global. I
considered doing an unset -f at the end of __get_cword4, but I made them
global (__break_index & __word_start) because they're used so often.
Thanks to Sung Pae (Alioth #312030):
"This patch extends both __get_cword3() and __get_cword4() to accept an
additional integer argument that specifies how many places previous to
the current word the desired word resides, respecting any user
exceptions to COMP_WORDBREAKS."