| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
| |
These helper methods aid in passing variables by reference.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Usage: _get_comp_words_by_ref [OPTIONS] [VARNAMES]
Available VARNAMES:
cur Return cur within varname "cur"
prev Return prev within varname "prev"
words Return words within varname "words"
cword Return cword within varname "cword"
Available OPTIONS:
-n EXCLUDE Characters out of $COMP_WORDBREAKS which should NOT be
considered word breaks. This is useful for things like scp
where we want to return host:path and not only path, so we
would pass the colon (:) as -n option in this case. Bash-3
doesn't do word splitting, so this ensures we get the same
word on both bash-3 and bash-4.
-c VARNAME Return cur within specified VARNAME
-p VARNAME Return prev within specified VARNAME
-w VARNAME Return words within specified VARNAME
-i VARNAME Return words within specified VARNAME
Example usage:
$ _get_comp_words_by_ref -n : cur prev
|
|
|
|
| |
COMP_WORDS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This solves the following problems:
- now one function call suffices instead of two (_get_cword; _get_pword) if
subsequent words need to be retrieved. Also more than two words can be
retrieved at once, e.g.: _get_comp_words_by_ref cur prev prev2 prev3
Also this prevents passing of `wordbreakchars' to differ in calls to
`_get_cword' and `_get_pword', e.g.: _get_comp_words_by_ref -n : cur prev
- passing by reference, no subshell call necessary anymore
- _get_pword now also takes into account the cursor position
Added testsuite proc `assert_no_output()'
Word of caution:
The passing-arguments-by-ref system in bash doesn't work if the new variable is
also declared local. For example:
t() {
local a
# ...
eval $1=b
}
a=c; t a; echo $a # Outputs "c", should be "b"
# Variable "a" is 'forbidden'
To make name collissions like this less likely to happen, but make the real
function still use readable variables, I've wrapped the `*_by_ref'
functions within an additional layer using variables prefixed with double
underscores (__). For example:
_t() {
# Readable variables can still be used here
local a
# ...
eval $1=b
}
t() {
local __a
_t __a
eval $1=\$__a
}
a=c; t a; echo $a # Outputs "b"
# Variable "__a" is 'forbidden'
Now only more obfuscated variables (starting with double prefix (__)) are
forbidden to use.
|
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Improve test suite.
Thanks to Leonard Crestez (Alioth: #311396, Debian: #511788).
`assert_complete' is improved. It proved difficult to tell tcl to ignore
backslash escapes, e.g. the `\b' is no BACKSPACE but a literal `b'. The added
function `split_words_bash' should to the trick now.
Added function `assert_no_complete' which can also be reached by calling
`assert_complete' with an empty `expected' argument:
assert_complete "" qwerty
|
|/ |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
On Debian/Ubuntu, awk (mawk 1.3.3 Nov 1996) is not supporting regexp
character classes. See also:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=314323
This was causing unit test `_known_hosts_real' to fail. To run the
test:
./run unit/_known_hosts_real.exp
|
|
|
|
|
|
|
|
| |
Some versions of the default word list for look may return
non-completable entries (e.g. due to sort order mismatch -- dictionary
vs non-dictionary one, case sensitivity etc -- between sort order in
default word list and look's defaults). As a side effect, fixes also
the test case when a lot of words are returned.
|
|
|
|
| |
There's no alternation functionality ('\|' or '|') in POSIX BRE.
|
|
|
|
| |
There's no alternation functionality ('\|' or '|') in POSIX BRE.
|
| |
|
| |
|
| |
|
|
|
|
| |
Use \{0,1\} (POSIX BRE) instead of \? or empty subexpression alternatives.
|
|
|
|
|
|
| |
For some reason, these constructs got flagged as syntax errors at load
time with bash 4.0.33(0)-release on FreeBSD 8.0 whereas they work
elsewhere I've tested (e.g. 4.0.23(1)-release on Fedora Core 11).
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
| |
Completing "a b " returned cur=b instead of cur=nothing if a wordbreak
character was specified.
|
|
|
|
|
|
|
|
|
| |
On bash-3, completing a b c: with COMP_WORDBREAKS -= : would result in the
current word being bc: (Alioth #312190)
Added unit test, run via:
./run unit/_get_cword.exp
|
| |
|
|
|
|
|
|
| |
This reverts commit dd5134a39a25f967cbc020b8a4d15807a2f5028e.
Okular doesn't open compressed .okular files.
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
| |
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().
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
| |
have known hosts or ssh config files or not.
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
| |
in function `__reassemble_comp_words_by_ref()'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|