File: autocompletion

package info (click to toggle)
openconnect 9.12-3.3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 12,336 kB
  • sloc: ansic: 40,846; sh: 7,073; xml: 3,785; python: 1,791; makefile: 973; java: 475; sed: 10
file content (78 lines) | stat: -rwxr-xr-x 1,576 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/sh
#
# Bash completion for OpenConnect
#
# Copyright © David Woodhouse <dwmw2@infradead.org>
#
# Author: David Woodhouse <dwmw2@infradead.org>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
# version 2.1, as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.


# Consider a command line like the following:
#
# openconnect -c --authenticate\ -k -k "'"'"'.pem --authgroup 'foo
# bar' --o\s linux-64 myserver


OPENCONNECT="${OPENCONNECT:-${top_builddir}/openconnect}"

if ! [ -x $OPENCONNECT ]; then
    echo "$OPENCONNECT is not executable. Are you cross-compiling for Windows?"
    exit 77
fi

do_test()
{
	if [ "$(COMP_CWORD=$WORD $OPENCONNECT --autocomplete "$@")" != "$RESULT" ]; then
	   echo "Autocomplete failed (word $WORD) for '$@'"
	   exit 1
	fi
	echo "Autocomplete OK (word $WORD) for '$@'"
}

WORD=1
RESULT="HOSTNAME"
do_test ""

WORD=1
RESULT="--certificate"
do_test -c

WORD=3
RESULT="FILENAME
!*.@(pem|der|p12|crt)"
do_test foo -k ''

WORD=2
RESULT="--protocol"
do_test somehost --proto

WORD=1
RESULT="HOSTNAME"
do_test somehost --proto

WORD=3
RESULT="FILENAME
!*.@(pem|der|crt)"
do_test foo --cafile ''

WORD=4
RESULT="none
off
all
stateless"
do_test -k foo --compr ''

WORD=1
RESULT="EXECUTABLE
''
-s"
do_test -s/bin