This fixes a bug under bash-4 where completing:
scp -F 'spaced conf' <TAB>
causes `dequote' to yield errors:
bash: eval: line 1: unexpected EOF while looking for matching `''
bash: eval: line 2: syntax error: unexpected end of file
The bug occurs because of a bug in bash-4.0, where quoted words are split
unintended, see: http://www.mail-archive.com/bug-bash@gnu.org/msg06095.html
Workaround is now to silence `dequote' in case of errors and wait for bash-4 to
be fixed...
Closes Alioth #311614
Globbing might occur if $cur contains one of these globbing characters: * ? [ ]
The bug becomes apparent:
On Cygwin if the glob-string contains backslashes as well, causing a warning (Cygwin >= 1.7):
MS-DOS style path detected: ...
Preferred POSIX equivalent is: ...
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
On Linux, using strace, you can see bash-completion doing an unnecessary `open' system call.
Steps to reproduce on Linux using `strace':
Environment: Linux, bash-completion-1.0
1. Start bash with bash-completion loaded and find out PID ($$):
$ echo $$
MYPID
2. In a second bash shell, `strace' the above PID:
$ strace -e trace=open -f -o strace.log -p MYPID
3. Within the first bash shell, type:
$ cur="?"; _kernel_versions
4. In the second bash shell, type ^C to quick `strace'.
5. Check `strace.log', here you can see bash accessing
something it shouldn't:
...
open(".", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 3
...
6. The above call to `open' disappears if $cur in _kernel_versions gets
quoted, and you repeat the steps above:
_kernel_versions()
{
COMPREPLY=( $( compgen -W '$( command ls /lib/modules )' -- "$cur" ) )
}
Needed to add okular-specific completions: xps, epub, odt, fb, mobi,
g3 and chm.
Also, okular can read any of its formats also in .gz/.bz2 compressed
format, so change the regular expression to match this.
- Added code comments to _get_cword, __get_cword3 & __get_cword4
- (testsuite) Added tests for _get_cword
- (testsuite) Bugfixes assert_bash_exec() && match_items()
Bash-4 splits COMP_WORDS using characters from COMP_WORDBREAKS, but has
a bug where quoted words are also splitted, see:
http://www.mail-archive.com/bug-bash@gnu.org/msg06095.html
__get_cword3 is used for bash-2/3 and __get_cword4 is used for bash-4.
__get_cword4 handles well temporarily disabling of COMP_WORDBREAK
characters, but fails quoted words (a 'b c) and subshells (a $(b c).
See the expected failures when running the automated tests.
__get_cword3 does a better job of returning quoted words.
To run the automated tests on bash-3/4:
$ ./runUnit _get_cword.exp [--tool_exec <path to bash-3/4 binary>]
`_get_cword' is reverted to before commit f6497298.
This fixes unittest:
"a b:c| with WORDBREAKS -= : should return b:c"
(| = cursor position)
notably by restoring passing an argument to _get_cword to omit
characters from $COMP_WORDBREAKS.
At the end of `get_cword', `echo "$cur"' has been changed to `printf
"%s" "$cur"'. This fixes unittest:
"a -n| should return -n"
(| = cursor position)
This reverts commit 11d4d978876ceb58eaec5dcfd82fae7b9699acfd.
Avoiding breaking completion for the sudo'd command isn't as
straightforward as I thought.
See also bugreport Alioth #311614.
Added tests for the awk script processing IP numbers. To run the tests:
cd test
./runUnit _known_hosts_real.exp
./runCompletion ssh.exp scp.exp sftp.exp
Quote sed output ("\1") retrieving "GlobalKnownHostsFile/UserKnownHostsFile" to
prevent bash globbing of special characters, e.g. '*'.
Added unit test "Config file containing star (*) should work".
Added test library function `assert_bash_list()'.
To run unit tests:
cd test && ./runUnit _known_hosts_real.exp
`_known_hosts_real' will add hosts from HOSTFILE (compgen -A hostname), unless
`COMP_KNOWN_HOSTS_WITH_HOSTFILE' is set to an empty value.
To run the unit tests:
$ cd test && ./runUnit _known_hosts_real.exp
This mimics the old behaviour where you could reuse `_known_hosts()' as
a helper function and pass it `-a' or `-c'.
NOTE: Using `_known_hosts' as a helper function and passing options to
`_known_hosts' is deprecated: Use `_known_hosts_real' instead.
Fixed `_known_hosts_real' to allow for multiple patterns in ssh config, e.g.:
Host foo.example.net bar.example.net
IFS was set to just newline (\n), whereas `compgen -W' relies on IFS
being space-tab-newline ( \t\n) to expand hostnames which are separated
by whitespace.
Tests are updated as well (added host `jar' to config). To run the tests:
./runUnit _known_hosts_real.exp
The original call to avahi-browse also had "-k", to avoid
lookups into avahi's services DB. We don't need the name
of the service, and if it contains ";", it may mistify
the result. But on Gentoo (at least), -k isn't available
(even if mentioned in the manpage), so...