90 Commits

Author SHA1 Message Date
Ville Skyttä
882649b712 Protect various compgen invocations from -* leakage (Debian: #766163) 2014-11-01 21:48:35 +02:00
Igor Murzov
23ac38333e testsuite/_filedir: Remove the cruft from the a\$b->h unit test (Alioth: #313480) 2012-09-06 18:36:49 +04:00
Igor Murzov
98f90ebdf8 _filedir: Properly quote paths to avoid unexpected expansion. 2012-01-20 05:11:17 +04:00
Ville Skyttä
5882061fec Revert "testsuite(_filedir): Ignore compopt error msg when invoking _filedir directly."
This reverts commit 8726cb1970510c4af90cd5655c09818fcef663ce.
2012-01-01 14:35:05 +02:00
Ville Skyttä
8726cb1970 testsuite(_filedir): Ignore compopt error msg when invoking _filedir directly.
The error message is printed since commit 5fcaad8.
2012-01-01 14:21:08 +02:00
Ville Skyttä
260e2a1eeb quote: Preserve leading, trailing, and consecutive whitespace. 2011-12-12 00:22:09 +02:00
Ville Skyttä
17c9722733 _known_hosts_real: Support > 1 files per *KnownHostsFile line (Debian: #650514). 2011-12-05 21:58:04 +02:00
Ville Skyttä
3af9222e96 _parse_help, _parse_usage: If first arg is "-", read from stdin. 2011-11-25 08:45:59 +02:00
Igor Murzov
4d76b721f4 testsuite: Set correct COMP_POINT value in test. 2011-11-09 18:14:59 +03:00
Igor Murzov
588facb6b6 testsuite: Add one more test for _get_comp_words_by_ref()
This test exposes bug in __get_cword_at_cursor_by_ref().
2011-11-09 04:54:52 +03:00
Ville Skyttä
333a5a50be _known_hosts_real: Handle more than two hostnames per known hosts line (Debian: #647352). 2011-11-05 00:53:39 +02:00
Ville Skyttä
102a19c8a2 _parse_help: Treat " or " as a separator when parsing options. 2011-07-10 15:25:23 +03:00
Ville Skyttä
a52c4ea382 __parse_options: Remove trailing [().]* from completions. 2011-06-18 15:44:43 +03:00
Freddy Vulto
fc96a951b7 Fix error "bad array subscript"
Caused by _get_comp_words_by_ref() with cursor at position 0.
Patch by Igor Murzov (Debian: #559953)
2011-05-19 22:40:14 +02:00
Ville Skyttä
b8b46f9c27 _parse_help: Pick long options also from "-f FOO, --foo=FOO". 2011-05-11 19:28:17 +03:00
Ville Skyttä
3334711726 _parse_usage: Deal with whitespace in brackets. 2011-05-05 00:06:58 +03:00
Ville Skyttä
68f6f1c685 _parse_usage, _parse_help: Add _parse_usage, expand [no-] and [dont-?] as well in _parse_help. 2011-05-02 14:37:13 +03:00
Ville Skyttä
c875723bef Include trailing equals sign in options that take arguments that way.
This way it's clearer to users that an argument is expected.  It's
likely that this commit does not catch all such cases, but it should
do it for most of the affected commands I have installed.
2011-05-02 11:45:55 +03:00
Ville Skyttä
41ce815827 testsuite: Add some failing _get_comp_words_by_ref testcases when cursor is before first word. 2011-05-01 17:33:24 +03:00
Ville Skyttä
0448c765ba testsuite: Add test case for Debian: #622383.
The fix is in commit 4ad538ba1a0ccb483899b4eaa70cc604d2b7bf78.
2011-05-01 16:00:07 +03:00
Ville Skyttä
7fb4e3137d _parse_help: Don't treat tokens with more than two leading dashes as options. 2011-04-29 12:05:29 +03:00
Ville Skyttä
b6cdacf1f9 _parse_help: Expand --[no]foo to --foo and --nofoo. 2011-04-29 11:47:48 +03:00
Ville Skyttä
fd2bd342e0 _parse_help: Fix --foo={bar,quux} handling. 2011-04-28 20:48:48 +03:00
Ville Skyttä
9d810be86b _parse_help: Make work with pipe separated options. 2011-04-27 23:22:03 +03:00
Ville Skyttä
7b60fc6555 _parse_help: Re-fix --foo[=bar] handling. 2011-04-27 21:44:04 +03:00
Ville Skyttä
5cd5993211 _parse_help: Change to output first long option, or first short if not found.
Makes things more consistent with the rest of our option offerings.
2011-04-27 18:36:52 +03:00
Ville Skyttä
6589a0d61b Drop support for bash < 4.1, clean up no longer needed low hanging cruft. 2011-04-21 12:20:59 +03:00
Freddy Vulto
68e9a8e6eb (testsuite) Add -unsorted option to _get_hosts()
_known_hosts_real tests were failing after commit 81794a9:

   FAIL: Hosts should be put in COMPREPLY
   FAIL: Hosts should have username prefix and colon suffix

This is because tcl's get_hosts() is now doing a unique sort, but bash
_known_hosts_real() IS returning duplicates relying on bash's compgen/complete
to remove the duplicates).  Fixed by calling _get_hosts -unsorted.
2011-03-27 23:12:14 +02:00
Freddy Vulto
7cd17ada11 Fix __reassemble_comp_words_by_ref() unquoted pattern removal
Commit 8227e76 was failing on these `chown' tests in bash-4.1:

    FAIL: Check preserve special chars in funky\ user:Debia<TAB>
    FAIL: Check preserve special chars in funky\.user:Debia<TAB>
    FAIL: Check preserve special chars in fu\ nky.user:Debia<TAB>
    FAIL: Check preserve special chars in f\ o\ o\.\bar:Debia<TAB>
    FAIL: Check preserve special chars in foo\_b\ a\.r\ :Debia<TAB>

because a removal pattern is expanded:

    $ a=\\b
    $ w=\\
    $ echo ${a#$w}    # Doesn't work
    \b
    $ echo ${a#"$w"}  # Ok
    b
2011-03-27 22:08:55 +02:00
Freddy Vulto
8227e76e09 Improve __reassemble_comp_words_by_ref() (Alioth #313057)
Prohibit word creation of characters if they're excluded from
$COMP_WORDBREAKS.  For example, with ':' included in $COMP_WORDBREAKS,
'a b:' should split to 'b' and ':'.  With ':' excluded from
$COMP_WORDBREAKS, 'a b:' should split to 'b:', NOT 'b' and ':'.
2011-03-24 00:00:58 +01:00
Freddy Vulto
11da957e45 (testsuite) `match_items()' matches on bash-prompt
Also made `match_items()' more strict about matching
space/newline/prompt after the last item.

Added options to match_items():
- end-newline
- end-prompt
- end-space
and transferred them to other functions.

Function `assert_complete()' now has a `-nospace' option to explicitly
disallow a space after a completion...

Function `assert_bash_list()' now expects a single item to be followed
by a newline.
2010-11-17 23:36:58 +01:00
Freddy Vulto
bc0bf2815c (testsuite) Uncomment testcases 2010-11-16 23:21:05 +01:00
Freddy Vulto
69f9c7c77e (testsuite) Fix _count_args tests to output newline
assert_bash_list() expects a newline terminated list

Plus small fixes to assert_bash_list_dir()
2010-11-16 23:06:13 +01:00
Freddy Vulto
c86b336769 (testuite) Fix tests to run with autotools' make distcheck
File locations are prefixed with `$::srcdir' so that `make distcheck' can
execute the test suite using a relative path.

The current working directory is removed from the test-suite-bash-prompt.

Furthermore, no more dynamic creation of files in dir $::srcdir/fixtures since
this dir is read-only during `make distcheck'.  Instead create dynamic files in
$TESTDIR/tmp

The test suite uses these "directory" variables

   tcl            bash          description
   ------------   -----------   ------------------------------------
   $::srcdir      $SRCDIR       where `fixtures' reside, relative
   $::srcdirabs   $SRCDIRABS    where `fixtures' reside, absolute
   $::TESTDIR     $TESTDIR      where `runtest' is invoked, absolute
2010-11-12 23:35:36 +01:00
Freddy Vulto
83bcd69557 (testsuite) Fix _parse_help for LANG=POSIX
Steps to reproduce the problem:

    $ LANG=POSIX ./run unit/_parse_help.exp
    ...
    Running ./unit/_parse_help.exp ...
    FAIL: short + long
    FAIL: short + long, slash separated

Cause:
When comparing list items, `assert_bash_list()' expects the real list to be
sorted, whereas the output of `_parse_help' is unsorted.
These particular two tests were failing because they suffered the
following LANG-dependant sort-difference:

    $ cat t.txt
    -m
    --n
    $ LANG=en_US.UTF-8 sort t.txt
    -m
    --n
    $ LANG=POSIX sort t.txt
    --n
    -m

Solution:
Made to default for `assert_bash_list' more-intuitive: unsorted, and added an
option `-sort' to explicitly enable sorting.

I felt uncomfortable adding yet another optional argument, so I seized this
opportunity to move subsequent optional arguments to single optional arguments.
E.g.:

    assert_bash_list {expected cmd {test ""} {prompt /@} {size 20}} {

has now become:

    # ...
    # @param list $args  Options:
    #     -nosort         Compare list unsorted.  Default is sorted
    #     -prompt         Bash prompt.  Default is `/@'
    #     -chunk-size N   Compare list N items at a time.  Default
    #                     is 20.
    assert_bash_list {expected cmd test {args {}}

(and the `test' argument has become mandatory).
2010-10-31 17:51:14 +01:00
Freddy Vulto
50dd6c7ac6 (testsuite) Test for expect-5.44 to prevent segfault
Modified test title
2010-10-31 07:53:15 +01:00
Freddy Vulto
20f7d5c1d2 (testsuite) Improve _filedir unicode test (Alioth #312477) 2010-10-26 22:41:01 +02:00
Freddy Vulto
37f51b9df2 (testsuite) Removed changing locale within 'expect'
Changing the locale within an `expect' session might cause bash to exit.
See: http://www.mail-archive.com/bash-completion-devel@lists.alioth.debian.org/msg02265.html
2010-10-18 22:29:59 +02:00
Ville Skyttä
96c6416309 Make _parse_help() work with slash separated options. 2010-10-11 00:39:50 +03:00
Ville Skyttä
95399f638c Fix false posives for non-option words in _parse_help (Alioth: #312750, Stephen Gildea). 2010-10-11 00:01:51 +03:00
Freddy Vulto
dff4241998 (testsuite) Fix _filedir test for "compgen -f" hack
One test was failing on bash-3
2010-10-09 22:12:51 +02:00
Freddy Vulto
e8d84b3004 Bugfix __reassemble_comp_words_by_ref
a b:c |<TAB> (with |=cursor) did not return `b:c' as `prev' on bash-4.1
(Alioth #312740)
2010-10-05 21:39:58 +02:00
Ville Skyttä
1da64f602a More known hosts IPv6 completion fixes, thanks to Yoshinori KUNIGA.
https://bugzilla.redhat.com/show_bug.cgi?id=630658#c4
2010-10-04 21:31:03 +03:00
Ville Skyttä
9341a1131c Fix known hosts completion for IPv6 addresses whose last 16 bits are digits (Alioth: #312695, RedHat: #630658). 2010-09-28 18:24:35 +03:00
Ville Skyttä
7f5c64e580 (testsuite) Add some [host]:port cases to known hosts related tests. 2010-09-28 17:59:31 +03:00
Ville Skyttä
c183a585b2 Match uppercased versions of _filedir and _filedir_xspec arguments too.
This provides a bit of case insensivity to file extension matching,
allowing for example _filedir foo to match both *.foo and *.FOO.  Note
that this is not real case insensivity; mixed case extensions like
*.FOO.gz are not matched by _filedir foo.gz so those need to be
handled like before this change.
2010-09-19 12:12:06 +03:00
Freddy Vulto
ccbf141e13 Fix tilde (~) completion with _filedir
This fixes tilde completion when doing for instance `ls ~<TAB>'.  See
also: Alioth #312613.

Added _tilde() helper function.

Contrary to _expand() and __expand_tilde_by_ref(), _tilde() also leaves the
tilde (~) intact.  Replacement of the tilde has been a complaint in other
bugreports, especially since plain bash completion (without bash-completion
installed) doesn't expand the tilde when doing a `ls ~<TAB>'.

To run the tests:

    ./run completion/ls.exp
    ./run unit/_tilde.exp
2010-06-30 23:28:31 +02:00
Freddy Vulto
51b3e20ebc (testsuite) Drop ending block comments
Instead of writing `}; # if', write just `}' as was discussed here:

    http://www.mail-archive.com/bash-completion-devel@lists.alioth.debian.org/msg01815.html
2010-06-18 17:21:38 +02:00
Freddy Vulto
94372b2aa6 Merge branch 'use-_get_comp_words_by_ref' 2010-06-10 23:51:30 +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