regardless of $cur beginning with ' or not"), because this is failing
tests:
FAIL: completing f a\'b/ should return i
FAIL: completing f a\"b/ should return i
FAIL: f a\$b/ should show completions
FAIL: f a\\b/ should show completions
FAIL: completing f2 a\'b/ should return i
FAIL: completing f2 a\"b/ should return i
FAIL: f2 a\$b/ should show completions
FAIL: f2 a\\b/ should show completions
- Fix _filedir to check for availability of COMP_WORDS (_filedir runs from
within a completion instead of the command line) when doing a `complete -p
${COMP_WORDS[0]'
- Fix _filedir usage comment
- Enhanced _filedir tests
- Added _filedir test "completing with filter '.e1' should show completions"
This can be triggered when $cur is actually empty, like, for example, when _filedir
is manually launched from the command line:
$ _filedir in
$ echo ${COMPREPLY[@]}
test doc .git contrib
i.e. it's only showing the directories, not showing the files we're looking for.
After this commit:
$ . bash_completion
$ _filedir in
$ echo ${COMPREPLY[@]}
test doc .git contrib bash_completion.sh.in Makefile.in
$
Which is the expected behaviour.
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.
- assert_source_completions()
- is_bash_completion_installed_for()
This allows for cleaner invocation of tests in `lib/completions/'. For
example, `completion/perldoc.exp' now just contains:
assert_source_completions perldoc
Skeleton test files for a command can be generated with:
$ ./generate <command>