Dash:
[t2.git] / package / shells / bashcompletion / rock-tools
blob9f3c3ee598eddbc87391dbc52d126e34b2584dba
1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
3
4 # T2 SDE: package/.../bashcompletion/rock-tools
5 # Copyright (C) 2004 - 2008 The T2 SDE Project
6 # Copyright (C) 1998 - 2004 ROCK Linux Project
7
8 # More information can be found in the files COPYING and README.
9
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; version 2 of the License. A copy of the
13 # GNU General Public License can be found in the file COPYING.
14 # --- T2-COPYRIGHT-NOTE-END ---
16 _interfaces() {
17         COMPREPLY=( $( compgen -W "$( command \
18                         sed -ne 's|^interface \([^ ]\+\).*$|\1|p' \
19                         /etc/network/config )" -- $cur ) )
22 _mine_installed_packages() {
23         COMPREPLY=( $( compgen -W "`(cd /var/adm/packages; echo *)`" -- $cur ) )
26 _mine() {
27         local cur prev
29         COMPREPLY=()
30         cur=${COMP_WORDS[COMP_CWORD]}
31         prev=${COMP_WORDS[COMP_CWORD-1]}
33         if [ $COMP_CWORD -eq 1 ]; then
34                 case "$cur" in
35                 *)
36                         COMPREPLY=( $( compgen -W '-i -r -q -p -l -m -c -d -k -C -T' \
37                                         -- $cur ) )
38                         ;;
39                 esac
41         return 0
42         fi
44         case "$prev" in
45         -R)
46                 _filedir -d
47                 return 0
48                 ;;
49         -k)
50                 COMPREPLY=( $( compgen -W 'pkg_name pkg_version pkg_tarbz2  \
51                                 pkg_config packages flists md5sums cksums   \
52                                 dependencies descs creator COPY I TITLE T   \
53                                 TEXT U URL A AUTHOR M MAINTAINER C CATEGORY \
54                                 F FLAG R ARCH ARCHITECTURE E DEP DEPENDENCY \
55                                 L LICENSE S STATUS V VER VERSION P PRI      \
56                                 PRIORITY CV-URL CV-PAT CV-DEL O CONF D DOWN \
57                                 DOWNLOAD SRC SOURCEPACKAGE' -- $cur ) )
58                 return 0
59         esac
61         case "${COMP_WORDS[1]}" in
62         -i)
63                 if [[ "$cur" == -* ]]; then
64                         COMPREPLY=( $( compgen -W '-t -v -f -R' -- $cur ) )
65                 else
66                         _filedir 'gem'
67                 fi
68                 ;;
69         -r)
70                 if [[ "$cur" == -* ]]; then
71                         COMPREPLY=( $( compgen -W '-t -v -f -R' -- $cur ) )
72                 else
73                         _mine_installed_packages
74                 fi
75                 ;;
76         -[qplmcd])
77                 if [[ "$cur" == -* ]]; then
78                         COMPREPLY=( $( compgen -W '-h -H' -- $cur ) )
79                 else
80                         _mine_installed_packages
81                         _filedir 'gem'
82                 fi
83                 ;;
84         -k)
85                 if [[ "$cur" == -* ]]; then
86                         COMPREPLY=( $( compgen -W '-h -H' -- $cur ) )
87                 else
88                         _filedir 'gem'
89                 fi
90                 ;;
91         -C)
92                 case "$COMP_CWORD" in
93                 2)
94                         _filedir -d
95                         ;;
96                 3)
97                         _filedir 'tar.bz2'
98                         ;;
99                 4)
100                         _mine_installed_packages
101                         ;;
102                 esac
103                 ;;
104         -T)
105                 case "$COMP_CWORD" in
106                 2|3)
107                         _filedir -d
108                         ;;
109                 4)
110                         _mine_installed_packages
111                         ;;
112                 esac
113         esac
115         return 0
117 complete -F _mine $filenames mine
119 _rc()
121         COMPREPLY=()
122         cur=${COMP_WORDS[COMP_CWORD]}
123         prev=${COMP_WORDS[COMP_CWORD-1]}
125         if [ $COMP_CWORD -eq 1 ]; then
126                 #first parameter on line
127                 if [ -r /etc/rc.d/init.d ]; then
128                 COMPREPLY=( $( compgen  -W "`(cd /etc/rc.d/init.d; echo *)`" \
129                                 -- $cur ) )
130                 fi
131         return 0
132         fi
134         if [ $COMP_CWORD -eq 2 ]; then
135                 #second parameter on line
136                 COMPREPLY=( $( compgen -W "$( command rc $prev help | \
137                         cut -d{ -f2 | tr -d '{}|' )" \
138                         -- $cur ) )
139         return 0
140         fi
142 complete -F _rc $filenames rc
143