1271 Commits

Author SHA1 Message Date
Ville Skyttä
487088e1d2 Weed out duplicate known hosts files to check.
https://bugzilla.redhat.com/show_bug.cgi?id=541423#c4
2009-11-26 23:49:32 +02:00
Ville Skyttä
76de7c2984 Fix handling of known hosts files starting with ~.
https://bugzilla.redhat.com/show_bug.cgi?id=541423#c3

Done by adding the eval back.  The only thing that this breaks AFAIK
is handling of known hosts filenames that have more than one
consecutive space in them, but I couldn't figure out how to get both
to work and IMO support for files starting with ~ is much more
important.
2009-11-26 23:30:04 +02:00
Ville Skyttä
6f921d563b Fix reading rest of user/global known hosts files when the first one is not readable.
https://bugzilla.redhat.com/show_bug.cgi?id=541423#c2

As a side effect, this simplifies things somewhat and grabs user and
global known hosts filenames from config files with one command
instead of doing one for each.
2009-11-26 21:59:12 +02:00
Ville Skyttä
b424bfe37b Use [[ ]] when appropriate per current style guidelines. 2009-11-23 20:08:52 +02:00
Ville Skyttä
29baa6b720 Fix modprobe -r completion when a path to modprobe is specified. 2009-11-23 17:32:48 +02:00
Freddy Vulto
4230265870 Fix completion of filenames containing colon.
This fixes the auto tests for `finger' and `ssh' on machines where an IPv6 host
"::1" is mentioned in /etc/hosts.
Added helper function __ltrim_colon_completions.

To run the tests:

    ./runCompletion finger.exp ssh.exp
2009-11-22 22:22:35 +01:00
David Paleino
29f4b10890 Added colordiff completion, same as diff 2009-11-21 14:38:41 +01:00
Ville Skyttä
36eb06af6b Extract CD/DVD completion from k3b into general functions, use them in mplayer. 2009-11-04 23:12:44 +02:00
Ville Skyttä
db7d2833df Indentation/linewrap fixes. 2009-11-04 00:24:28 +02:00
Ville Skyttä
41c675e749 sed usage portability fixes: avoid semicolon separated statements in one -e. 2009-11-04 00:16:06 +02:00
Ville Skyttä
ef46331012 Fix service argument completion. 2009-11-03 23:36:01 +02:00
Ville Skyttä
5b54c41de5 Fix javadoc, lvm, and mkinitrd (_count_args) local variable leaks. 2009-11-03 22:49:14 +02:00
Ville Skyttä
c820944d2e Be stricter when finding long options in _longopt. 2009-11-03 22:28:10 +02:00
Ville Skyttä
4790b1a0c6 sed usage portability fixes: avoid \+ 2009-11-03 22:04:46 +02:00
Ville Skyttä
ac644578e0 More compgen -W instead of embedding user input in sed/awk/grep fixes. 2009-11-01 21:01:18 +02:00
Ville Skyttä
f1b3be2357 Drop compgen/complete option and bash version related global variables. 2009-10-31 14:40:24 +02:00
Ville Skyttä
82c2334e4c Add /sbin to $PATH when invoking ifconfig and iwconfig. 2009-10-31 14:05:19 +02:00
Freddy Vulto
884c3f5af6 Fixes to _get_pword patch.
Changed the last `echo' to a `printf' to make completing `-n' or '-e'
come through.  Declaring a function local (break_index & word_start)
also doesn't work on my machine: the functions become visible global.  I
considered doing an unset -f at the end of __get_cword4, but I made them
global (__break_index & __word_start) because they're used so often.
2009-10-31 09:55:40 +01:00
Freddy Vulto
545750eb2c Added _get_pword() helper function.
Thanks to Sung Pae (Alioth #312030):
"This patch extends both __get_cword3() and __get_cword4() to accept an
additional integer argument that specifies how many places previous to
the current word the desired word resides, respecting any user
exceptions to COMP_WORDBREAKS."
2009-10-31 09:24:20 +01:00
Ville Skyttä
eb5e62dec1 Drop internal uses of $bash4 (definition still present though). 2009-10-22 12:10:34 +03:00
Ville Skyttä
885e6dd6b6 Drop internal uses of $default, $filenames and friends.
Definitions are still present though, tentatively scheduled for
removal as of 2.0.
2009-10-22 12:04:29 +03:00
Ville Skyttä
f194a2d753 bash < 3 support removal step 4: drop unneeded version checks. 2009-10-22 11:50:20 +03:00
Ville Skyttä
a6cf003275 Set version to 2.x. 2009-10-22 11:17:10 +03:00
Ville Skyttä
6862bb45c1 bash < 3 support removal step 1: drop unneeded conditional sections. 2009-10-22 11:15:27 +03:00
Ville Skyttä
bc6ad9b75b Source stuff from completion dirs always in same order independently of locale. 2009-10-21 20:44:19 +03:00
Ville Skyttä
cbd15cc8a0 Don't bother defining __get_cwordX on non-applicable bash versions. 2009-10-20 22:22:47 +03:00
Ville Skyttä
1ce1e0d452 Don't overwrite other completions when completing from multiple SSH known hosts files. 2009-10-20 20:05:30 +03:00
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