1325 Commits

Author SHA1 Message Date
Freddy Vulto
0118ccb05a Remove verbose options from `_upvars'. 2010-06-10 00:03:07 +02:00
Freddy Vulto
a8dd58cfa9 Added _upvars' and _upvar'.
These helper methods aid in passing variables by reference.
2010-06-09 22:37:02 +02:00
Freddy Vulto
f894f07500 Fix comment 2010-03-14 11:21:56 +01:00
Freddy Vulto
bdca37a7bf Improve _get_comp_words_by_ref to return words' and cword'
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
2010-03-14 11:07:13 +01:00
David Paleino
f8bafe285e Use _get_comp_words_by_ref to set cur, prev, [..] instead of manually using COMP_WORDS 2010-02-08 17:25:08 +01:00
Freddy Vulto
b529cee550 Added _get_comp_words_by_ref()
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.
2010-02-07 15:18:58 +01:00
Freddy Vulto
1061876bbc Merge branch 'fvu' 2010-01-29 23:24:58 +01:00
Freddy Vulto
d866854066 Fix _usergroup, cpio and chown completions
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
2010-01-29 23:23:30 +01:00
Ildar Mulyukov
3438a5547a Add showmount completion (Alioth: #312285). 2010-01-26 23:33:24 +02:00
Ville Skyttä
ab05989877 Do not alias sed to gsed (Alioth: #311393). 2010-01-19 21:59:08 +02:00
Ville Skyttä
7914d17468 Avoid use of POSIX character classes with awk for mawk compatibility. 2010-01-19 19:09:15 +02:00
Ville Skyttä
08e746ea10 Add pbzip2, pbunzip2, and pbzcat completions. 2010-01-18 19:21:08 +02:00
Ville Skyttä
43681ffac6 Make _parse_help() look at stderr too. 2010-01-18 19:09:02 +02:00
Ville Skyttä
df1a02baa5 Add pigz and unpigz completion. 2010-01-18 18:54:39 +02:00
Freddy Vulto
2f78769d65 Removed awk regexp character classes.
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
2010-01-17 10:41:13 +01:00
Ville Skyttä
f8eec776e2 Weed out look completions not starting with current word.
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.
2010-01-16 17:30:02 +02:00
Ville Skyttä
ea0ee6a46b Fix installing simple xspec completions on systems with non-GNU sed.
There's no alternation functionality ('\|' or '|') in POSIX BRE.
2010-01-16 15:38:49 +02:00
Ville Skyttä
878c9dd5c9 Fix finding known hosts files from SSH configs on systems with non-GNU sed.
There's no alternation functionality ('\|' or '|') in POSIX BRE.
2010-01-16 15:22:49 +02:00
Ville Skyttä
1fe72c982e Update years in copyright notice. 2010-01-14 19:33:21 +02:00
Ville Skyttä
dfc8e9bb8f Apply xine and friends completion also to dragon. 2010-01-13 20:36:01 +02:00
Freddy Vulto
d5d7592169 Fix _known_hosts_real: awkcurd > curd 2010-01-06 09:31:31 +01:00
Ville Skyttä
db739401f7 sed portability fixes.
Use \{0,1\} (POSIX BRE) instead of \? or empty subexpression alternatives.
2010-01-04 18:15:10 +02:00
Ville Skyttä
2a5a1d68d9 Fix some syntax errors.
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).
2010-01-03 21:18:41 +02:00
Guillaume Rousse
2cf62de308 protect against error when used in history context (COMP_CWORD=0) 2010-01-03 19:01:56 +01:00
Ville Skyttä
aae256d7e0 Do basic HTML file completion with Firefox and Chrome and friends, and Epiphany. 2010-01-03 14:21:08 +02:00
Ville Skyttä
9c2843a956 Remove/rephrase some obsolete bash 2 related comments. 2010-01-03 14:03:38 +02:00
Ville Skyttä
86070a8f60 Fix __expand_tilde_by_ref usage example. 2010-01-03 13:50:14 +02:00
Ville Skyttä
563e4d355d Split mount and umount completion into contrib/mount. 2010-01-02 10:35:18 +02:00
Freddy Vulto
3f0bfbc5ae Fix __reassemble_comp_words_by_ref()
Completing "a b " returned cur=b instead of cur=nothing if a wordbreak
character was specified.
2009-12-31 11:12:15 +01:00
Freddy Vulto
3251038c9d Fix __reassemble_comp_words_by_ref()
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
2009-12-30 09:43:16 +01:00
Ville Skyttä
eee39d7b66 Re-fix *.okular addition, this time without matching compressed ones. 2009-12-28 23:50:24 +02:00
David Paleino
8299cd3616 Revert "Fix *.okular addition."
This reverts commit dd5134a39a25f967cbc020b8a4d15807a2f5028e.

  Okular doesn't open compressed .okular files.
2009-12-28 21:28:16 +01:00
Ville Skyttä
dd5134a39a Fix *.okular addition. 2009-12-28 22:25:47 +02:00
David Paleino
db3c386fd3 Added .okular completion to okular (Debian: #545530) 2009-12-27 19:07:24 +01:00
Ville Skyttä
8f56de625e Fix $2 example in _get_cword doc. 2009-12-24 15:31:19 +02:00
Freddy Vulto
c9c98da36e Fixed `quote_readline'.
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().
2009-12-24 10:00:29 +01:00
Ville Skyttä
3d9f8206e1 Use awk more to reduce number of invoked commands a bit. 2009-12-21 23:00:31 +02:00
Ville Skyttä
6807b5e72d Replace some echos with printfs. 2009-12-21 00:09:02 +02:00
Ville Skyttä
c755d7becc Replace some uses of ls with printf. 2009-12-20 23:44:33 +02:00
Ville Skyttä
8caddc47cf Protect grep invocations from user aliases (Alioth: 312143). 2009-12-15 23:48:10 +02:00
Ville Skyttä
5d691d4826 Complete aliases also when there are no known hosts files (RedHat: #546905). 2009-12-13 11:41:55 +02:00
Ville Skyttä
a358902e90 Include avahi host completions in known hosts completions no matter if we have known hosts or ssh config files or not. 2009-12-13 11:33:54 +02:00
Ville Skyttä
b72a0f6e26 Get rid of one unnecessary local variable. 2009-12-13 11:31:06 +02:00
Ville Skyttä
798bd2328e Doc and line wrapping fixes. 2009-12-13 11:28:14 +02:00
David Paleino
bf1d64153f Added .fdf completion to okular and evince 2009-12-11 17:49:23 +01:00
Ville Skyttä
733811a7b1 Don't append space after colon in _usergroup (bash 4 only). 2009-12-11 00:39:59 +02:00
Ville Skyttä
8f68300a0d Add wordbreak filtering to _count_args. 2009-12-11 00:14:54 +02:00
Freddy Vulto
b1e58b1a0e Fix __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
2009-12-10 21:28:24 +01:00
Freddy Vulto
098dc9c1b8 Remove unused local variable `wordbreaks'
in function `__reassemble_comp_words_by_ref()'
2009-12-07 09:28:49 +01:00
Freddy Vulto
08c5878483 Merged __get_cword3 & __get_cword4 to _get_cword
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.
2009-12-06 23:16:31 +01:00