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*.
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
Err, TERM=linux also causes errors when tests are run via cron.
Reset TERM=dummy.
Workaround is to do a CRON=running from within the cron job and only set
TERM=dummy when not run via cron.
The TERM=dummy setting causes backspaces (^H) to appear in stdout when running
from cron. Changing to TERM=linux should fix the ^H's in stdout AND the bug of
`meta_on' or `meta_off' escape sequences in stdout, caused by a bug in
supposedly libreadline5:
http://old.nabble.com/-PATCH-:-fix-libreadline5-linked-applications-sending-meta_on-or-meta_off-to-stdout-td25557585.html
Steps to reproduce output of ^H with TERM=dummy:
$ batch
warning: commands will be executed using /bin/sh
at> ./runUnit _known_hosts_real.exp --debug < /dev/tty40
at> ^D
NOTE: You need to connect a terminal (< /dev/tty..) to the test suite
when running from cron. See also doc/testing.txt, "Running tests via
cron".
- Refactored code to new function `_remove_cword_from_cmd()'
- Added `cword' parameter to `assert_complete()' and `assert_complete_dir()':
@param string $cword (optional) Last argument of $cmd which is an
argument-to-complete and to be replaced with the longest common
prefix of $expected. If empty string (default), `assert_complete'
autodetects if the last argument is an argument-to-complete by
checking if $cmd doesn't end with whitespace. Specifying `cword'
is only necessary if this autodetection fails, e.g. when the last
whitespace is escaped or quoted, e.g. "finger foo\ " or
"finger 'foo "