1244 Commits

Author SHA1 Message Date
Freddy Vulto
0dda212d95 Indents 2009-10-18 12:38:04 +02:00
David Paleino
bb8912b06f Don't use pidof in _known_hosts_real() to detect whether Avahi is available
It's not available on MacOS X.
    Thanks to Rainer Müller <raimue@codingfarm.de>
    (bash-completion MacPorts maintainer)
2009-10-11 11:12:09 +02:00
Guillaume Rousse
463568bc48 pattern based file completions are defined in main file 2009-10-04 23:02:55 +02:00
Guillaume Rousse
b56a8dfaae fix conflicts 2009-10-04 19:46:01 +02:00
Guillaume Rousse
506e1cb3eb new indentation policy 2009-10-04 19:42:50 +02:00
Freddy Vulto
1be84710d2 Silence completing scp/sftp/ssh -F '' on bash-4
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...
2009-10-04 18:14:16 +02:00
Freddy Vulto
8455b7ef38 Fix comment 2009-10-03 23:27:40 +02:00
Ville Skyttä
369980bf93 Tell *Emacs to indent comments (sh-indent-comment: t).
Also move indentation settings to end of files and expand *Emacs ones to
local variables block to avoid overflowing 80 char lines.
2009-10-01 20:54:51 +03:00
Freddy Vulto
e6a18ac7cf Quoted $cur to prevent globbing
See Alioth #311614
2009-09-28 20:21:54 +02:00
Freddy Vulto
32f22b996a Quoted $cur to prevent quoting
See Alioth #311614, bash-completion.patch3
2009-09-25 21:30:45 +02:00
Freddy Vulto
cfcf9fae8f Quote unquoted $cur to prevent globbing.
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" ) )
    }
2009-09-25 09:36:29 +02:00
David Paleino
975e950192 Split okular from evince filename extension completion, add okular-specific completions.
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.
2009-09-23 23:38:52 +02:00
Ville Skyttä
aa45595251 Add /sbin to $PATH when invoking lspci and lsusb. 2009-09-20 18:33:24 +03:00
Freddy Vulto
f733e71e1f Split _get_cword into bash-3/4 versions
- 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>]
2009-09-20 14:11:26 +02:00
David Paleino
f061b21ef9 Clean [1.2.3.4]:port format in known_hosts, thanks to Xuefer (Gentoo: #284563) 2009-09-17 23:05:52 +02:00
David Paleino
3a69bd3e93 Improve service(8) completion, also look for "msg_usage" (thanks to Elan Ruusamäe <glen@delfi.ee>) 2009-09-17 22:24:21 +02:00
David Paleino
f13ea4968b Avoid sed pipe as ps itself can omit the headers (thanks to Elan Ruusamäe) 2009-09-17 22:20:29 +02:00
Freddy Vulto
e663e1cbc0 Reverted _get_cword
`_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)
2009-09-07 00:30:09 +02:00
Ville Skyttä
b5505959af Don't hardcode path to lsmod. 2009-09-06 18:51:00 +03:00
Ville Skyttä
47fb2d8f0e Revert "Improve sudo completion (Alioth: #311414)."
This reverts commit 11d4d978876ceb58eaec5dcfd82fae7b9699acfd.
Avoiding breaking completion for the sudo'd command isn't as
straightforward as I thought.
2009-09-05 00:26:48 +03:00
Freddy Vulto
de585f387d Fix _known_hosts_real() to not glob awk script
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
2009-09-04 23:08:56 +02:00
Ville Skyttä
11d4d97887 Improve sudo completion (Alioth: #311414). 2009-09-04 23:59:34 +03:00
Freddy Vulto
31f03cfb82 Fix for known_host files containing * character
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
2009-08-23 09:38:19 +02:00
Ville Skyttä
1ed4fa2f62 Comment tweaks. 2009-08-18 11:45:47 +03:00
Ville Skyttä
405e33deed Do not require a dot in bzcmp, bzdiff, bz*grep, zcmp, zdiff, z*grep, zless, and zmore filename completions. 2009-08-18 11:31:39 +03:00
Ville Skyttä
e074f7ff83 Complete bzcat and zcat only on compressed files. 2009-08-18 11:22:16 +03:00
Ville Skyttä
8c43004135 Add lz*grep, lzless, and lzmore completion. 2009-08-18 11:15:01 +03:00
Ville Skyttä
7e92537bad Add $compopt (":" i.e. noop with bash < 4, "compopt" with >= 4). 2009-08-12 23:49:27 +03:00
Freddy Vulto
a1f5b2e2d0 Fix _known_hosts_real() comment 2009-08-12 22:28:42 +02:00
Freddy Vulto
2e87bd4c01 Added setting COMP_KNOWN_HOSTS_WITH_HOSTFILE
`_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
2009-08-12 22:20:56 +02:00
Freddy Vulto
57565c1ce2 Merge branch 'fvu' 2009-08-11 21:09:19 +02:00
Freddy Vulto
ce5384234c Fixed _known_hosts_real indentation 2009-08-11 21:08:25 +02:00
Ville Skyttä
dcc30c71c2 Add *.ogv to xine-based players (Debian: #540033). 2009-08-05 23:47:15 +03:00
Ville Skyttä
f8319fa0ea Add *.lzma to xz, unxz and xzcat completions. 2009-07-30 18:35:58 +03:00
Ville Skyttä
c6360dde51 Trim trailing whitespace (cosmetic, no functional changes). 2009-07-25 13:38:42 +03:00
Freddy Vulto
6d31b15011 Fix backwards compatibility calls to _known_hosts
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.
2009-07-25 09:35:03 +02:00
Ville Skyttä
a490556a5b Fix leaking $prev from _service(). 2009-07-23 00:37:33 +03:00
Ville Skyttä
06eed586ee Add lzcat and unlzma completion. 2009-07-20 20:00:33 +03:00
Ville Skyttä
d3d1a9f895 Add xz, xzcat, xzdec, and unxz completion. 2009-07-20 19:57:36 +03:00
Ville Skyttä
e34f96e50d Associate *.po with poedit, gtranslator, kbabel, and lokalize. 2009-07-13 18:28:42 +03:00
Freddy Vulto
3fe193f81a Fix completing multiple hosts (Debian: #535585)
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
2009-07-07 23:05:03 +02:00
Freddy Vulto
25e4eb6df3 Gave _known_hosts_real mandatory argument CWORD
The option `-h hostname' to `_known_hosts_real' is removed.
2009-07-03 22:28:13 +02:00
Ville Skyttä
c78e27cd7c Associate .tsv with oocalc. 2009-07-02 22:57:01 +03:00
Ville Skyttä
2b56b95caa Associate OOXML/MS Office 2007 extensions with OpenOffice tools. 2009-07-02 22:54:05 +03:00
David Paleino
9f192ba339 Remove -k from avahi-browse call
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...
2009-06-20 22:45:14 +02:00
Freddy Vulto
2770bc6927 Merge branch 'fvu' 2009-06-20 09:37:50 +02:00
Freddy Vulto
8858c8df33 Tidied getopts-check loop in _known_hosts_real 2009-06-20 09:34:46 +02:00
David Paleino
976fafa07e Oops :) 2009-06-20 09:17:06 +02:00
David Paleino
1ab50e301e Merge branch 'master' of git+ssh://git.debian.org/git/bash-completion/bash-completion 2009-06-20 09:14:35 +02:00
David Paleino
1e532f0f2b Check whether avahi-daemon is started 2009-06-20 09:14:08 +02:00