~ubuntu-branches/ubuntu/karmic/bash-completion/karmic

« back to all changes in this revision

Viewing changes to bash-completion_20060301-3ubuntu2.debdiff

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2008-04-15 01:21:38 UTC
  • Revision ID: james.westby@ubuntu.com-20080415012138-pker4fsl17s92uty
Tags: 20060301-3ubuntu3
Don't use ucf for handling the bash_completion config file. Avoids
prompting the user for a changed config file, if the config file is
unchanged (and only moved to the bash-completion package). LP: #210013.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
diff -u bash-completion-20060301/debian/changelog bash-completion-20060301/debian/changelog
2
 
--- bash-completion-20060301/debian/changelog
3
 
+++ bash-completion-20060301/debian/changelog
4
 
@@ -1,3 +1,20 @@
5
 
+bash-completion (20060301-3ubuntu2) hardy; urgency=low
6
 
+
7
 
+  * Bugfix release:
8
 
+   - Fix _get_cword more
9
 
+   - Fix _command function to correctly prune the command line (LP: #103395)
10
 
+   - Remove newline from options pattern for dpkg (LP: #138312)
11
 
+   - Start readline-quoting arguments to compgen (LP: #123665)
12
 
+   - Save and restore -v shell option (LP: #205444)
13
 
+   - Prevent glob expansion in _filedir function (LP: #194419)
14
 
+   - Quote glob expression in tar completion function (LP: #194419)
15
 
+   - Complete AAS/SSA files for mplayer -sub (LP: #151086)
16
 
+   - Disable completion of postgresql users and databases (LP: #164772)
17
 
+   - Use files from UserKnownHostsFile options in addition to standard ones
18
 
+     (LP: #211180)
19
 
+
20
 
+ -- Mika Fischer <mika.fischer@zoopnet.de>  Sat, 05 Apr 2008 16:09:34 +0200
21
 
+
22
 
 bash-completion (20060301-3ubuntu1) hardy; urgency=low
23
 
 
24
 
   * Bug fix upload (LP: #194860)
25
 
diff -u bash-completion-20060301/bash_completion bash-completion-20060301/bash_completion
26
 
--- bash-completion-20060301/bash_completion
27
 
+++ bash-completion-20060301/bash_completion
28
 
@@ -25,7 +25,17 @@
29
 
 #
30
 
 #   RELEASE: 20060301
31
 
 
32
 
-[ -n "${BASH_COMPLETION_DEBUG:-}" ] && set -v || set +v
33
 
+if [[ $- == *v* ]]; then
34
 
+       BASH_COMPLETION_ORIGINAL_V_VALUE="-v"
35
 
+else
36
 
+       BASH_COMPLETION_ORIGINAL_V_VALUE="+v"
37
 
+fi
38
 
+
39
 
+if [[ -n $BASH_COMPLETION_DEBUG ]]; then
40
 
+       set -v
41
 
+else
42
 
+       set +v
43
 
+fi
44
 
 
45
 
 # Alter the following to reflect the location of this file.
46
 
 #
47
 
@@ -177,40 +187,61 @@
48
 
     [[ "$( bind -v )" = *$1+([[:space:]])on* ]]
49
 
 }
50
 
 
51
 
+# This function shell-quotes the argument
52
 
+quote()
53
 
+{
54
 
+       echo \'${1//\'/\'\\\'\'}\' #'# Help vim syntax highlighting
55
 
+}
56
 
+
57
 
+# This function quotes the argument in a way so that readline dequoting
58
 
+# results in the original argument
59
 
+quote_readline()
60
 
+{
61
 
+       local t="${1//\\/\\\\}"
62
 
+       echo \'${t//\'/\'\\\'\'}\' #'# Help vim syntax highlighting
63
 
+}
64
 
+
65
 
+# This function shell-dequotes the argument
66
 
+dequote()
67
 
+{
68
 
+       eval echo "$1"
69
 
+}
70
 
+
71
 
+
72
 
 # Get the word to complete
73
 
 # This is nicer than ${COMP_WORDS[$COMP_CWORD]}, since it handles cases
74
 
 # where the user is completing in the middle of a word.
75
 
 # (For example, if the line is "ls foobar",
76
 
 # and the cursor is here -------->   ^
77
 
 # it will complete just "foo", not "foobar", which is what the user wants.)
78
 
-#
79
 
-# Accepts an optional parameter indicating which characters out of
80
 
-# $COMP_WORDBREAKS should NOT be considered word breaks. This is useful
81
 
-# for things like scp where we want to return host:path and not only path.
82
 
 _get_cword()
83
 
 {
84
 
-       local i
85
 
-       local WORDBREAKS=${COMP_WORDBREAKS}
86
 
-       if [ -n $1 ]; then
87
 
-               for (( i=0; i<${#1}; ++i )); do
88
 
-                       local char=${1:$i:1}
89
 
-                       WORDBREAKS=${WORDBREAKS//$char/}
90
 
+       if [[ "${#COMP_WORDS[COMP_CWORD]}" -eq 0 ]] || [[ "$COMP_POINT" == "${#COMP_LINE}" ]]; then
91
 
+               echo "${COMP_WORDS[COMP_CWORD]}"
92
 
+       else
93
 
+               local i
94
 
+               local cur="$COMP_LINE"
95
 
+               local index="$COMP_POINT"
96
 
+               for (( i = 0; i <= COMP_CWORD; ++i )); do
97
 
+                       while [[ "${#cur}" -ge ${#COMP_WORDS[i]} ]] && [[ "${cur:0:${#COMP_WORDS[i]}}" != "${COMP_WORDS[i]}" ]]; do
98
 
+                               cur="${cur:1}"
99
 
+                               index="$(( index - 1 ))"
100
 
+                       done
101
 
+                       if [[ "$i" -lt "$COMP_CWORD" ]]; then
102
 
+                               local old_size="${#cur}"
103
 
+                               cur="${cur#${COMP_WORDS[i]}}"
104
 
+                               local new_size="${#cur}"
105
 
+                               index="$(( index - old_size + new_size ))"
106
 
+                       fi
107
 
                done
108
 
-       fi
109
 
-       local cur=${COMP_LINE:0:$COMP_POINT}
110
 
-       local tmp="${cur}"
111
 
-       local word_start=`expr "$tmp" : '.*['"${WORDBREAKS}"']'`
112
 
-       while [ "$word_start" -ge 2 ]; do
113
 
-               local char=${cur:$(( $word_start - 2 )):1}
114
 
-               if [ "$char" != "\\" ]; then
115
 
-                       break
116
 
-               fi
117
 
-               tmp=${COMP_LINE:0:$(( $word_start - 2 ))}
118
 
-               word_start=`expr "$tmp" : '.*['"${WORDBREAKS}"']'`
119
 
-       done
120
 
 
121
 
-       cur=${cur:$word_start}
122
 
-       echo $cur
123
 
+               if [[ "${COMP_WORDS[COMP_CWORD]:0:${#cur}}" != "$cur" ]]; then
124
 
+                       # We messed up! At least return the whole word so things keep working
125
 
+                       echo "${COMP_WORDS[COMP_CWORD]}"
126
 
+               else
127
 
+                       echo "${cur:0:$index}"
128
 
+               fi
129
 
+       fi
130
 
 }
131
 
 
132
 
 
133
 
@@ -221,23 +252,23 @@
134
 
 #
135
 
 _filedir()
136
 
 {
137
 
-       local IFS=$'\t\n' xspec #glob
138
 
+       local IFS=$'\t\n' xspec
139
 
 
140
 
        _expand || return 0
141
 
 
142
 
-       #glob=$(set +o|grep noglob) # save glob setting.
143
 
-       #set -f          # disable pathname expansion (globbing)
144
 
-
145
 
-       if [ "${1:-}" = -d ]; then
146
 
-               COMPREPLY=( ${COMPREPLY[@]:-} $( compgen -d -- $cur ) )
147
 
-               #eval "$glob"    # restore glob setting.
148
 
-               return 0
149
 
+       local toks=( ) tmp
150
 
+       while read -r tmp; do
151
 
+               [[ -n $tmp ]] && toks[${#toks[@]}]=$tmp
152
 
+       done < <( compgen -d -- "$(quote_readline "$cur")" )
153
 
+
154
 
+       if [[ "$1" != -d ]]; then
155
 
+               xspec=${1:+"!*.$1"}
156
 
+               while read -r tmp; do
157
 
+                       [[ -n $tmp ]] && toks[${#toks[@]}]=$tmp
158
 
+               done < <( compgen -f -X "$xspec" -- "$(quote_readline "$cur")" )
159
 
        fi
160
 
 
161
 
-       xspec=${1:+"!*.$1"}     # set only if glob passed in as $1
162
 
-       COMPREPLY=( ${COMPREPLY[@]:-} $( compgen -f -X "$xspec" -- "$cur" ) \
163
 
-                   $( compgen -d -- "$cur" ) )
164
 
-       #eval "$glob"    # restore glob setting.
165
 
+       COMPREPLY=( "${COMPREPLY[@]}" "${toks[@]}" )
166
 
 }
167
 
 
168
 
 # This function completes on signal names
169
 
@@ -306,12 +337,12 @@
170
 
 #
171
 
 _expand()
172
 
 {
173
 
-       [ "$cur" != "${cur%\\}" ] && cur="$cur\\"
174
 
+       # FIXME: Why was this here?
175
 
+       # [ "$cur" != "${cur%\\}" ] && cur="$cur\\"
176
 
 
177
 
        # expand ~username type directory specifications
178
 
        if [[ "$cur" == \~*/* ]]; then
179
 
                eval cur=$cur
180
 
-               
181
 
        elif [[ "$cur" == \~* ]]; then
182
 
                cur=${cur#\~}
183
 
                COMPREPLY=( $( compgen -P '~' -u $cur ) )
184
 
@@ -385,7 +416,7 @@
185
 
        COMPREPLY=( $( builtin echo $sysvdir/!(*.rpmsave|*.rpmorig|*~|functions)) )
186
 
 
187
 
        if [ -d $famdir ]; then
188
 
-               COMPREPLY=( ${COMPREPLY[@]} $( builtin echo $famdir/!(*.rpmsave|*.rpmorig|*~)) )
189
 
+               COMPREPLY=( "${COMPREPLY[@]}" $( builtin echo $famdir/!(*.rpmsave|*.rpmorig|*~)) )
190
 
        fi
191
 
 
192
 
        COMPREPLY=( $( compgen -W '${COMPREPLY[@]#@($sysvdir|$famdir)/}' -- $cur ) )
193
 
@@ -1041,7 +1072,7 @@
194
 
                            # remove word from list of completions
195
 
                            COMPREPLY=( ${COMPREPLY/ ${i%% *} / } )
196
 
                        done
197
 
-                       echo ${COMPREPLY[@]})
198
 
+                       echo "${COMPREPLY[@]}")
199
 
                  ) )
200
 
        
201
 
        _filedir
202
 
@@ -1070,7 +1101,7 @@
203
 
                essid)
204
 
                        COMPREPLY=( $( compgen -W 'on off any' -- $cur ) )
205
 
                        if [ -n "${COMP_IWLIST_SCAN:-}" ]; then
206
 
-                               COMPREPLY=( ${COMPREPLY[@]:-} \
207
 
+                               COMPREPLY=( "${COMPREPLY[@]}" \
208
 
                                        $( iwlist ${COMP_WORDS[1]} scan | \
209
 
                                        awk -F '"' '/ESSID/ {print $2}' | \
210
 
                                        grep "^$cur" ))
211
 
@@ -1097,7 +1128,7 @@
212
 
                ap)
213
 
                        COMPREPLY=( $( compgen -W 'on off any' -- $cur ) )
214
 
                        if [ -n "${COMP_IWLIST_SCAN:-}" ]; then
215
 
-                               COMPREPLY=( ${COMPREPLY[@]:-} \
216
 
+                               COMPREPLY=( "${COMPREPLY[@]}" \
217
 
                                        $( iwlist ${COMP_WORDS[1]} scan | \
218
 
                                        awk -F ': ' '/Address/ {print $2}' | \
219
 
                                        grep "^$cur" ) )
220
 
@@ -1106,7 +1137,7 @@
221
 
                        ;;
222
 
                rate)
223
 
                        COMPREPLY=( $( compgen -W 'auto fixed' -- $cur ) )
224
 
-                       COMPREPLY=( ${COMPREPLY[@]:-} \
225
 
+                       COMPREPLY=( "${COMPREPLY[@]}" \
226
 
                                $( iwlist ${COMP_WORDS[1]} rate | \
227
 
                                awk '/^[[:space:]]*[0-9]/ {print $1"M"}' | \
228
 
                                grep "^$cur" ) )
229
 
@@ -1391,7 +1422,7 @@
230
 
        fi
231
 
 
232
 
        qfile=0
233
 
-       for idx in ${COMP_WORDS[@]}; do
234
 
+       for idx in "${COMP_WORDS[@]}"; do
235
 
                [[ "$idx" = -q ]] && qfile=1 && break
236
 
        done
237
 
        if [[ $qfile == 1 ]]; then
238
 
@@ -1535,7 +1566,7 @@
239
 
        cur=`_get_cword`
240
 
 
241
 
        count=0
242
 
-       for i in ${COMP_WORDS[@]}; do
243
 
+       for i in "${COMP_WORDS[@]}"; do
244
 
                [ $count -eq $COMP_CWORD ] && break
245
 
                # Last parameter was the CVSROOT, now go back to mode selection
246
 
                if [ "${COMP_WORDS[((count))]}" == "$cvsroot" -a "$mode" == "cvsroot" ]; then
247
 
@@ -1605,7 +1636,7 @@
248
 
                                ;;
249
 
                        esac
250
 
                elif [[ "$i" = -* ]]; then
251
 
-                       flags=( ${flags[@]:-} $i )
252
 
+                       flags=( "${flags[@]}" $i )
253
 
                fi
254
 
                count=$((++count))
255
 
        done
256
 
@@ -1619,7 +1650,7 @@
257
 
                                [ -z "$cur" ] && \
258
 
                                files=$( command ls -Ad !(CVS) ) || \
259
 
                                files=$( command ls -d ${cur}* 2>/dev/null )
260
 
-                               for i in ${entries[@]:-}; do
261
 
+                               for i in "${entries[@]}"; do
262
 
                                        files=( ${files[@]/#$i//} )
263
 
                                done
264
 
                                COMPREPLY=( $( compgen -W '${files[@]}' -- \
265
 
@@ -1713,8 +1744,8 @@
266
 
                        if [ $COMP_CWORD -gt 1 -a -r ${prefix:-}CVS/Entries ]; then
267
 
                                get_entries
268
 
                                # find out what files are missing
269
 
-                               for i in ${entries[@]}; do
270
 
-                                       [ ! -r "$i" ] && miss=( ${miss[@]:-} $i )
271
 
+                               for i in "${entries[@]}"; do
272
 
+                                       [ ! -r "$i" ] && miss=( "${miss[@]}" $i )
273
 
                                done
274
 
                                COMPREPLY=( $(compgen -W '${miss[@]:-}' -- $cur) )
275
 
                        fi
276
 
@@ -1805,7 +1836,7 @@
277
 
        COMPREPLY=( $( rpm -qa $nodig $nosig --queryformat '%{group}\n' | \
278
 
                       grep "^$cur" ) )
279
 
        # backslash escape spaces and translate newlines to tabs
280
 
-       COMPREPLY=( $( echo ${COMPREPLY[@]} | sed 's/ /\\ /g' | tr '\n' '\t' ) )
281
 
+       COMPREPLY=( $( echo "${COMPREPLY[@]}" | sed 's/ /\\ /g' | tr '\n' '\t' ) )
282
 
 }
283
 
 
284
 
 # rpm(8) completion
285
 
@@ -2476,33 +2507,29 @@
286
 
            user_kh=$( eval echo $( sed -ne 's/^[ \t]*[Uu][Ss][Ee][Rr][Kk][Nn][Oo][Ww][Nn][Hh][Oo][Ss][Tt][Ss][Ff][Ii][Ll][Ee]['"$'\t '"']*\(.*\)$/\1/p' "${config[@]}" ) )
287
 
        fi
288
 
 
289
 
-       # choose which global known hosts file to use
290
 
-       if [ -r "$global_kh" ]; then
291
 
-           kh=( "$global_kh" )
292
 
-       else
293
 
-           [ -r /etc/ssh/ssh_known_hosts ] &&
294
 
-             kh=( ${kh[@]} /etc/ssh/ssh_known_hosts )
295
 
-           [ -r /etc/ssh/ssh_known_hosts2 ] &&
296
 
-             kh=( ${kh[@]} /etc/ssh/ssh_known_hosts2 )
297
 
-           [ -r /etc/known_hosts ] &&
298
 
-             kh=( ${kh[@]} /etc/known_hosts )
299
 
-           [ -r /etc/known_hosts2 ] &&
300
 
-             kh=( ${kh[@]} /etc/known_hosts2 )
301
 
-           [ -d /etc/ssh2/knownhosts ] &&
302
 
-             khd=( ${khd[@]} /etc/ssh2/knownhosts/*pub )
303
 
-       fi
304
 
-
305
 
-       # choose which user known hosts file to use
306
 
-       if [ -r "$user_kh" ]; then
307
 
-           kh=( ${kh[@]} "$user_kh" )
308
 
-       else
309
 
-           [ -r ~/.ssh/known_hosts ] &&
310
 
-             kh=( ${kh[@]} ~/.ssh/known_hosts )
311
 
-           [ -r ~/.ssh/known_hosts2 ] &&
312
 
-             kh=( ${kh[@]} ~/.ssh/known_hosts2 )
313
 
-           [ -d ~/.ssh2/hostkeys ] &&
314
 
-             khd=( ${khd[@]} ~/.ssh2/hostkeys/*pub )
315
 
-       fi
316
 
+       # Global known_hosts files
317
 
+       [ -r "$global_kh" ] &&
318
 
+           kh=( "${kh[@]}" "$global_kh" )
319
 
+       [ -r /etc/ssh/ssh_known_hosts ] &&
320
 
+           kh=( "${kh[@]}" /etc/ssh/ssh_known_hosts )
321
 
+       [ -r /etc/ssh/ssh_known_hosts2 ] &&
322
 
+           kh=( "${kh[@]}" /etc/ssh/ssh_known_hosts2 )
323
 
+       [ -r /etc/known_hosts ] &&
324
 
+           kh=( "${kh[@]}" /etc/known_hosts )
325
 
+       [ -r /etc/known_hosts2 ] &&
326
 
+           kh=( "${kh[@]}" /etc/known_hosts2 )
327
 
+       [ -d /etc/ssh2/knownhosts ] &&
328
 
+           khd=( "${khd[@]}" /etc/ssh2/knownhosts/*pub )
329
 
+
330
 
+       # User known_hosts files
331
 
+       [ -r "$user_kh" ] &&
332
 
+           kh=( "${kh[@]}" "$user_kh" )
333
 
+       [ -r ~/.ssh/known_hosts ] &&
334
 
+           kh=( "${kh[@]}" ~/.ssh/known_hosts )
335
 
+       [ -r ~/.ssh/known_hosts2 ] &&
336
 
+           kh=( "${kh[@]}" ~/.ssh/known_hosts2 )
337
 
+       [ -d ~/.ssh2/hostkeys ] &&
338
 
+           khd=( "${khd[@]}" ~/.ssh2/hostkeys/*pub )
339
 
 
340
 
        # If we have known_hosts files to use
341
 
        if [ ${#kh[@]} -gt 0 -o ${#khd[@]} -gt 0 ]; then
342
 
@@ -2532,18 +2559,18 @@
343
 
                                /^[^|]/ {for (i=1; i<=2; ++i) { \
344
 
                                       gsub(" .*$", "", $i); \
345
 
                                       if ($i ~ /'$cur'/) {print $i} \
346
 
-                               }}' ${kh[@]} 2>/dev/null ) )
347
 
+                               }}' "${kh[@]}" 2>/dev/null ) )
348
 
            fi
349
 
            if [ ${#khd[@]} -gt 0 ]; then
350
 
                # Needs to look for files called
351
 
                # .../.ssh2/key_22_<hostname>.pub
352
 
                # dont fork any processes, because in a cluster environment, 
353
 
                # there can be hundreds of hostkeys
354
 
-               for i in ${khd[@]} ; do
355
 
+               for i in "${khd[@]}" ; do
356
 
                    if [[ "$i" == *key_22_$curd*.pub ]] && [ -r "$i" ] ; then
357
 
                        host=${i/#*key_22_/}
358
 
                        host=${host/%.pub/}
359
 
-                       COMPREPLY=( ${COMPREPLY[@]} $host )
360
 
+                       COMPREPLY=( "${COMPREPLY[@]}" $host )
361
 
                    fi
362
 
                done
363
 
            fi
364
 
@@ -2552,11 +2579,11 @@
365
 
            if [ ${#config[@]} -gt 0 ] && [ -n "$aliases" ]; then
366
 
                local host_aliases=$( sed -ne 's/^[Hh][Oo][Ss][Tt]\([Nn][Aa][Mm][Ee]\)\?['"$'\t '"']\+\([^*?]*\)$/\2/p' "${config[@]}" )
367
 
                hosts=$( compgen -W "$host_aliases" -- $ocur )
368
 
-               COMPREPLY=( ${COMPREPLY[@]} $hosts )
369
 
+               COMPREPLY=( "${COMPREPLY[@]}" $hosts )
370
 
            fi
371
 
 
372
 
            # Now add results of normal hostname completion
373
 
-           COMPREPLY=( ${COMPREPLY[@]} $( compgen -A hostname -- $ocur ) )
374
 
+           COMPREPLY=( "${COMPREPLY[@]}" $( compgen -A hostname -- $ocur ) )
375
 
 
376
 
            # apply suffix
377
 
            for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
378
 
@@ -2599,7 +2626,7 @@
379
 
            _known_hosts -a
380
 
 
381
 
            [ $COMP_CWORD -eq 1 ] || \
382
 
-               COMPREPLY=( ${COMPREPLY[@]} $( compgen -c -- $cur ) )
383
 
+               COMPREPLY=( "${COMPREPLY[@]}" $( compgen -c -- $cur ) )
384
 
        esac
385
 
 
386
 
        return 0
387
 
@@ -2613,7 +2640,7 @@
388
 
        local cur userhost path
389
 
 
390
 
        COMPREPLY=()
391
 
-       cur=`_get_cword ":"`
392
 
+       cur=`_get_cword`
393
 
 
394
 
        _expand || return 0
395
 
 
396
 
@@ -2640,7 +2667,7 @@
397
 
 
398
 
        [[ "$cur" == */* ]] || _known_hosts -c -a
399
 
                local IFS=$'\t\n'
400
 
-               COMPREPLY=( ${COMPREPLY[@]} $( command ls -aF1d $cur* \
401
 
+               COMPREPLY=( "${COMPREPLY[@]}" $( command ls -aF1d $cur* \
402
 
                            2>/dev/null | sed \
403
 
                            -e "s/[][(){}<>\",:;^&!$&=?\`|\\ ']/\\\\&/g" \
404
 
                            -e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' ) )
405
 
@@ -2772,7 +2799,7 @@
406
 
                           # remove word from list of completions
407
 
                           COMPREPLY=( ${COMPREPLY/ $i / } )
408
 
                        done
409
 
-                      echo ${COMPREPLY[@]})
410
 
+                      echo "${COMPREPLY[@]}")
411
 
                  ) )
412
 
        return 0
413
 
 }
414
 
@@ -2931,7 +2958,7 @@
415
 
        fi
416
 
 
417
 
        # file completion on relevant files
418
 
-       _filedir $ext
419
 
+       _filedir "$ext"
420
 
 
421
 
        return 0
422
 
 }
423
 
@@ -3103,7 +3130,7 @@
424
 
        # we have a CDPATH, so loop on its contents
425
 
        for i in ${CDPATH//:/$'\t'}; do
426
 
                # create an array of matched subdirs
427
 
-               k=${#COMPREPLY[@]}
428
 
+               k="${#COMPREPLY[@]}"
429
 
                for j in $( compgen -d $i/$cur ); do
430
 
                        if [[ ( $mark_symdirs && -h $j || $mark_dirs && ! -h $j ) && ! -d ${j#$i/} ]]; then
431
 
                                j="${j}/"
432
 
@@ -3129,6 +3156,37 @@
433
 
     complete -F _cd $nospace $filenames cd
434
 
 fi
435
 
 
436
 
+_remove_comp_word()
437
 
+{
438
 
+       if [[ COMP_CWORD -eq 0 ]]; then
439
 
+               return
440
 
+       elif [[ ${#COMP_WORDS[@]} -ge 2 ]]; then
441
 
+               local old_cw0="${COMP_WORDS[0]}"
442
 
+               local new_cw0="${COMP_WORDS[1]}"
443
 
+               local old_length="${#COMP_LINE}"
444
 
+               COMP_LINE=${COMP_LINE#${old_cw0}}
445
 
+               local head=${COMP_LINE:0:${#new_cw0}}
446
 
+               local i=1
447
 
+               while [[ $head != $new_cw0 ]]; do
448
 
+                       COMP_LINE=${COMP_LINE:1}
449
 
+                       head=${COMP_LINE:0:${#new_cw0}}
450
 
+                       if (( ++i > 10 )); then
451
 
+                               break
452
 
+                       fi
453
 
+               done
454
 
+               local new_length="${#COMP_LINE}"
455
 
+               COMP_POINT=$(( COMP_POINT + new_length - old_length))
456
 
+
457
 
+               COMP_CWORD=$(( COMP_CWORD - 1 ))
458
 
+               for (( i=0; i < ${#COMP_WORDS[@]} - 1; ++i )); do
459
 
+                       COMP_WORDS[i]="${COMP_WORDS[i+1]}"
460
 
+               done
461
 
+               unset COMP_WORDS[${#COMP_WORDS[@]}-1]
462
 
+       else
463
 
+               return
464
 
+       fi
465
 
+}
466
 
+
467
 
 # A meta-command completion function for commands like sudo(8), which need to
468
 
 # first complete on a command, then complete according to that command's own
469
 
 # completion definition - currently not quite foolproof (e.g. mount and umount
470
 
@@ -3139,63 +3197,45 @@
471
 
        local cur func cline cspec noglob cmd done i \
472
 
              _COMMAND_FUNC _COMMAND_FUNC_ARGS
473
 
 
474
 
+       _remove_comp_word
475
 
        COMPREPLY=()
476
 
        cur=`_get_cword`
477
 
        # If the the first arguments following our meta-command-invoker are
478
 
        # switches, get rid of them. Most definitely not foolproof.
479
 
        done=
480
 
        while [ -z $done ] ; do
481
 
-           cmd=${COMP_WORDS[1]}
482
 
-           if [[ "$cmd" == -* ]] && [ $COMP_CWORD -gt 1 ]; then
483
 
-               for (( i=1 ; i<COMP_CWORD ; i++)) ; do
484
 
-                   COMP_WORDS[i]=${COMP_WORDS[i+1]}
485
 
-               done
486
 
-               COMP_CWORD=$(($COMP_CWORD-1))
487
 
+           cmd=${COMP_WORDS[0]}
488
 
+           if [[ "$cmd" == -* ]] && [ $COMP_CWORD -ge 1 ]; then
489
 
+               _remove_comp_word
490
 
+           elif [[ "$cmd" == -* ]] && [[ $COMP_CWORD -eq 0 ]]; then
491
 
+               return
492
 
            else 
493
 
                done=1
494
 
            fi
495
 
        done
496
 
 
497
 
-       if [ $COMP_CWORD -eq 1 ]; then
498
 
+       if [ $COMP_CWORD -eq 0 ]; then
499
 
                COMPREPLY=( $( compgen -c -- $cur ) )
500
 
        elif complete -p $cmd &>/dev/null; then
501
 
                cspec=$( complete -p $cmd )
502
 
                if [ "${cspec#* -F }" != "$cspec" ]; then
503
 
-                       # complete -F <function>
504
 
-                       #
505
 
                        # COMP_CWORD and COMP_WORDS() are not read-only,
506
 
                        # so we can set them before handing off to regular
507
 
                        # completion routine
508
 
 
509
 
-                       # set current token number to 1 less than now
510
 
-                       COMP_CWORD=$(( $COMP_CWORD - 1 ))
511
 
-
512
 
                        # get function name
513
 
                        func=${cspec#*-F }
514
 
                        func=${func%% *}
515
 
-                       # get current command line minus initial command
516
 
-                       cline="${COMP_LINE#*( )$1 }"
517
 
-                       # save noglob state
518
 
-                       shopt -qo noglob; noglob=$?
519
 
-                       # turn on noglob, as things like 'sudo ls *<Tab>'
520
 
-                       # don't work otherwise
521
 
-                       shopt -so noglob
522
 
-                       # split current command line tokens into array
523
 
-                       COMP_WORDS=( $cline )
524
 
-                       # reset noglob if necessary
525
 
-                       [ $noglob -eq 1 ] && shopt -uo noglob
526
 
-                       $func $cline
527
 
-                       # This is needed in case user finished entering
528
 
-                       # command and pressed tab (e.g. sudo ls <Tab>)
529
 
-                       COMP_CWORD=$(( $COMP_CWORD > 0 ? $COMP_CWORD : 1 ))
530
 
-                       cur=`_get_cword`
531
 
-                       _COMMAND_FUNC=$func
532
 
-                       _COMMAND_FUNC_ARGS=( $cmd $2 $3 )
533
 
-                       COMP_LINE=$cline
534
 
-                       COMP_POINT=$(( ${COMP_POINT} - ${#1} - 1 ))
535
 
-                       $func $cmd $2 $3
536
 
+
537
 
+                       if [[ ${#COMP_WORDS[@]} -ge 2 ]]; then
538
 
+                               $func $cmd "${COMP_WORDS[${#COMP_WORDS[@]}-1]}" "${COMP_WORDS[${#COMP_WORDS[@]}-2]}"
539
 
+                       else
540
 
+                               $func $cmd "${COMP_WORDS[${#COMP_WORDS[@]}-1]}"
541
 
+                       fi
542
 
+
543
 
                        # remove any \: generated by a command that doesn't
544
 
                        # default to filenames or dirnames (e.g. sudo chown)
545
 
+                       # FIXME: I'm pretty sure this does not work!
546
 
                        if [ "${cspec#*-o }" != "$cspec" ]; then
547
 
                                cspec=${cspec#*-o }
548
 
                                cspec=${cspec%% *}
549
 
@@ -3312,7 +3352,7 @@
550
 
        COMPREPLY=( $( compgen -W '-# -f -? -C -h -p -P -i -r -E -s -S -t -u \
551
 
                                              -v -V -w' -- $cur ) )
552
 
 
553
 
-       COMPREPLY=( ${COMPREPLY[@]} \
554
 
+       COMPREPLY=( "${COMPREPLY[@]}" \
555
 
                    $( compgen -W 'create drop extended-status flush-hosts \
556
 
                                   flush-logs flush-status flush-tables \
557
 
                                   flush-threads flush-privileges kill \
558
 
@@ -4010,6 +4050,7 @@
559
 
 have psql && {
560
 
 _pg_databases() 
561
 
 {
562
 
+       return
563
 
        COMPREPLY=( $( psql -l 2>/dev/null | \
564
 
                        sed -e '1,/^-/d' -e '/^(/,$d' | \
565
 
                        awk '{print $1}' | grep "^$cur" ) )
566
 
@@ -4017,9 +4058,10 @@
567
 
 
568
 
 _pg_users()
569
 
 {
570
 
-       COMPREPLY=( $( psql -qtc 'select usename from pg_user' template1 2>/dev/null | \
571
 
-                       grep "^ $cur" ) )
572
 
-       [ ${#COMPREPLY[@]} -eq 0 ] && COMPREPLY=( $( compgen -u -- $cur ) )
573
 
+       #COMPREPLY=( $( psql -qtc 'select usename from pg_user' template1 2>/dev/null | \
574
 
+       #               grep "^ $cur" ) )
575
 
+       #[ ${#COMPREPLY[@]} -eq 0 ] &&
576
 
+       COMPREPLY=( $( compgen -u -- $cur ) )
577
 
 }
578
 
 
579
 
 # createdb(1) completion
580
 
@@ -4276,8 +4318,7 @@
581
 
        fi
582
 
 
583
 
        case "$prev" in 
584
 
-       -@(c|i|A|I|f|e|x|X|-@(install|unpack|record-avail|contents|info| \
585
 
-                         fsys-tarfile|field|control|extract)))
586
 
+       -@(c|i|A|I|f|e|x|X|-@(install|unpack|record-avail|contents|info|fsys-tarfile|field|control|extract)))
587
 
                _filedir '?(u)deb'
588
 
                return 0
589
 
                ;;
590
 
@@ -4597,17 +4638,17 @@
591
 
        for i in ${classpath//:/ }; do
592
 
                if [ -r $i ] && [[ "$i" == *.@(jar|zip) ]]; then
593
 
                        if type zipinfo &> /dev/null; then
594
 
-                               COMPREPLY=( ${COMPREPLY[@]} $( zipinfo -1 \
595
 
+                               COMPREPLY=( "${COMPREPLY[@]}" $( zipinfo -1 \
596
 
                                "$i" | grep "^$cur" | grep '\.class$' | \
597
 
                                grep -v "\\$" ) )
598
 
                        else
599
 
-                               COMPREPLY=( ${COMPREPLY[@]} $( jar tf "$i" \
600
 
+                               COMPREPLY=( "${COMPREPLY[@]}" $( jar tf "$i" \
601
 
                                "$cur" | grep "\.class$" | grep -v "\\$" ) )
602
 
                        fi
603
 
 
604
 
                elif [ -d $i ]; then
605
 
                        i=${i%/}
606
 
-                       COMPREPLY=( ${COMPREPLY[@]} $( find "$i" -type f \
607
 
+                       COMPREPLY=( "${COMPREPLY[@]}" $( find "$i" -type f \
608
 
                        -path "$i/$cur*.class" 2>/dev/null | \
609
 
                        grep -v "\\$" | sed -e "s|^$i/||" ) )
610
 
                fi
611
 
@@ -4632,12 +4673,12 @@
612
 
        # parse each sourcepath element for packages
613
 
        for i in ${sourcepath//:/ }; do
614
 
                if [ -d $i ]; then
615
 
-                       COMPREPLY=( ${COMPREPLY[@]} $( command ls -F -d \
616
 
+                       COMPREPLY=( "${COMPREPLY[@]}" $( command ls -F -d \
617
 
                                $i/$cur* 2>/dev/null | sed -e 's|^'$i'/||' ) )
618
 
                fi
619
 
        done
620
 
        # keep only packages
621
 
-       COMPREPLY=( $( echo ${COMPREPLY[@]} | tr " " "\n" | grep "/$" ) )
622
 
+       COMPREPLY=( $( echo "${COMPREPLY[@]}" | tr " " "\n" | grep "/$" ) )
623
 
        # remove packages extension
624
 
        COMPREPLY=( ${COMPREPLY[@]%/} )
625
 
        # convert path syntax to package syntax
626
 
@@ -4821,7 +4862,7 @@
627
 
        shift
628
 
        while [[ "$1" ]]; do
629
 
            newconffiles=( $(sed -rn 's|^source[[:space:]]+([^[:space:]]+).*$|\1|p' $(eval echo $1) ) )
630
 
-           for file in ${newconffiles[@]}; do
631
 
+           for file in "${newconffiles[@]}"; do
632
 
                [[ ! "$file" ]] || [[ "${sofar/ ${file} / }" != "$sofar" ]] &&
633
 
                    continue
634
 
                sofar="$sofar $file"
635
 
@@ -4844,8 +4885,8 @@
636
 
 
637
 
        conffiles=( $(eval _muttconffiles $muttrc $muttrc) )
638
 
        aliases=( $( sed -rn 's|^alias[[:space:]]+([^[:space:]]+).*$|\1|p' \
639
 
-                       $(eval echo ${conffiles[@]}) ) )
640
 
-       COMPREPLY=( ${COMPREPLY[@]} $( compgen -W "${aliases[*]}" -- $cur ) )
641
 
+                       $(eval echo "${conffiles[@]}") ) )
642
 
+       COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W "${aliases[*]}" -- $cur ) )
643
 
 
644
 
        return 0
645
 
 }
646
 
@@ -4864,7 +4905,7 @@
647
 
              sed -nr '2,$s|^([^[:space:]]+).*|\1|p' ) )
648
 
        fi
649
 
 
650
 
-       COMPREPLY=( ${COMPREPLY[@]} $( compgen -W "${queryresults[*]}" \
651
 
+       COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W "${queryresults[*]}" \
652
 
                        -- $cur ) )
653
 
 
654
 
        return 0
655
 
@@ -5320,7 +5361,7 @@
656
 
            ;;
657
 
        *)
658
 
            _perlmodules
659
 
-           COMPREPLY=( ${COMPREPLY[@]} $( compgen -W '$( PAGER=cat man perl 2>/dev/null | sed -ne "/perl.*Perl overview/,/perlwin32/s/^[^a-z0-9]*\([a-z0-9]*\).*$/\1/p")' -- $cur ) )
660
 
+           COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W '$( PAGER=cat man perl 2>/dev/null | sed -ne "/perl.*Perl overview/,/perlwin32/s/^[^a-z0-9]*\([a-z0-9]*\).*$/\1/p")' -- $cur ) )
661
 
 
662
 
            return 0
663
 
            ;;
664
 
@@ -5550,7 +5591,7 @@
665
 
        COMPREPLY2=( $( egrep "^[^\|]+\|$portsdir$cur" < $indexfile | \
666
 
                        cut -d'|' -f2 ) )
667
 
        COMPREPLY2=( ${COMPREPLY2[@]#$portsdir} )
668
 
-       COMPREPLY=( ${COMPREPLY[@]} ${COMPREPLY2[@]} )
669
 
+       COMPREPLY=( "${COMPREPLY[@]}" "${COMPREPLY2[@]}" )
670
 
 
671
 
        return 0
672
 
 } &&
673
 
@@ -5654,13 +5695,13 @@
674
 
                        return 0
675
 
                        ;;
676
 
                -sub)
677
 
-                       _filedir '@(srt|SRT|sub|SUB|txt|TXT|utf|UTF|rar|RAR|mpsub|smi|js)'
678
 
+                       _filedir '@(srt|SRT|sub|SUB|txt|TXT|utf|UTF|rar|RAR|mpsub|smi|js|ssa|SSA|aas|AAS)'
679
 
                        return 0
680
 
                        ;;
681
 
                -vobsub)
682
 
                        _filedir '@(idx|IDX|ifo|IFO|sub|SUB)'
683
 
                        IFS=$'\t\n' 
684
 
-                       COMPREPLY=( $( for i in ${COMPREPLY[@]}; do
685
 
+                       COMPREPLY=( $( for i in "${COMPREPLY[@]}"; do
686
 
                                                if [ -f $i -a -r $i ]; then
687
 
                                                        echo ${i%.*}
688
 
                                                else
689
 
@@ -5897,7 +5938,7 @@
690
 
                                        -bps -oldpp -nozoom -noflip -nounicode \
691
 
                                        -noutf8' -- $cur ) )
692
 
                        # add mplayer specific options
693
 
-                       [[ "$cmd" == @(?(g)mplayer) ]] && COMPREPLY=( ${COMPREPLY[@]} \
694
 
+                       [[ "$cmd" == @(?(g)mplayer) ]] && COMPREPLY=( "${COMPREPLY[@]}" \
695
 
                                $(compgen -W '-autoq -autosync -benchmark \
696
 
                                        -framedrop -h -help -hardframedrop \
697
 
                                        -identify -input -lircconf -loop \
698
 
@@ -5928,7 +5969,7 @@
699
 
                                        -aaosdcolor -aasubcolor -aadriver \
700
 
                                        -aaextended -aaeight' -- $cur) )
701
 
                        # add mencoder specific options
702
 
-                       [[ "$cmd" = mencoder ]] && COMPREPLY=( ${COMPREPLY[@]} \
703
 
+                       [[ "$cmd" = mencoder ]] && COMPREPLY=( "${COMPREPLY[@]}" \
704
 
                                $(compgen -W '-audio-density -audio-delay \
705
 
                                        -audio-preload -divx4opts -endpos \
706
 
                                        -ffourcc -include -info -lameopts \
707
 
@@ -6036,7 +6077,7 @@
708
 
        -@(r|-recipient))
709
 
                COMPREPLY=( $( compgen -W "$( gpg --list-keys 2>/dev/null | sed -ne 's@^pub.*<\([^>]*\)>.*$@\1@p')" -- "$cur" ))
710
 
                if [ -e ~/.gnupg/gpg.conf ]; then
711
 
-                       COMPREPLY=( ${COMPREPLY[@]} $( compgen -W "$( sed -ne 's@^[ \t]*group[ \t][ \t]*\([^=]*\).*$@\1@p' ~/.gnupg/gpg.conf  )" -- "$cur") )
712
 
+                       COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W "$( sed -ne 's@^[ \t]*group[ \t][ \t]*\([^=]*\).*$@\1@p' ~/.gnupg/gpg.conf  )" -- "$cur") )
713
 
                fi
714
 
                return 0
715
 
                ;;
716
 
@@ -6216,10 +6257,10 @@
717
 
        # files are always eligible completion
718
 
        _filedir
719
 
        # track options are always available
720
 
-       COMPREPLY=( ${COMPREPLY[@]} $( compgen -W '${track_options[@]}' -- $cur ) )
721
 
+       COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W '${track_options[@]}' -- $cur ) )
722
 
        # general options are no more available after file or track option
723
 
        if [ $track_mode -eq 0 ]; then
724
 
-               COMPREPLY=( ${COMPREPLY[@]} \
725
 
+               COMPREPLY=( "${COMPREPLY[@]}" \
726
 
                            $( compgen -W '${generic_options[@]}' -- $cur ) )
727
 
        fi
728
 
 
729
 
@@ -6948,7 +6989,7 @@
730
 
        fi
731
 
 
732
 
 }
733
 
-complete -F _aspell $default aspell
734
 
+complete -F _aspell $filenames aspell
735
 
 }
736
 
 
737
 
 # xmms(1) completion
738
 
@@ -9299,9 +9340,17 @@
739
 
        xspec=${xspec#*-X }
740
 
        xspec=${xspec%% *}
741
 
 
742
 
-       COMPREPLY=( $( eval compgen -f -X "$xspec" -- \
743
 
-                   \"${cur#[\`\"\']}\" 2>/dev/null ) \
744
 
-                   $( compgen -d -- $cur ) )
745
 
+       local toks=( ) tmp
746
 
+
747
 
+       while read -r tmp; do
748
 
+               [[ -n $tmp ]] && toks[${#toks[@]}]=$tmp
749
 
+       done < <( compgen -d -- "$(quote_readline "$cur")" )
750
 
+
751
 
+       while read -r tmp; do
752
 
+               [[ -n $tmp ]] && toks[${#toks[@]}]=$tmp
753
 
+       done < <( eval compgen -f -X $xspec -- "\$(quote_readline "\$cur")" )
754
 
+
755
 
+       COMPREPLY=( "${toks[@]}" )
756
 
 }
757
 
 list=( $( sed -ne '/^# START exclude/,/^# FINISH exclude/p' \
758
 
          $BASH_COMPLETION | \
759
 
@@ -9314,16 +9363,16 @@
760
 
                line=${line%# START exclude*}
761
 
                line=${line%# FINISH exclude*}
762
 
                line=${line##*\'}
763
 
-               list=( ${list[@]:-} $line )
764
 
+               list=( "${list[@]}" $line )
765
 
        done
766
 
-       echo ${list[@]}
767
 
+       echo "${list[@]}"
768
 
        )
769
 
      ) )
770
 
 # remove previous compspecs
771
 
 if [ ${#list[@]} -gt 0 ]; then
772
 
     eval complete -r ${list[@]}
773
 
     # install new compspecs
774
 
-    eval complete -F _filedir_xspec $filenames ${list[@]}
775
 
+    eval complete -F _filedir_xspec $filenames "${list[@]}"
776
 
 fi
777
 
 unset list
778
 
 
779
 
@@ -9344,6 +9393,9 @@
780
 
 unset UNAME RELEASE default dirnames filenames have nospace bashdefault \
781
 
       plusdirs
782
 
 
783
 
+set $BASH_COMPLETION_ORIGINAL_V_VALUE
784
 
+unset BASH_COMPLETION_ORIGINAL_V_VALUE
785
 
+
786
 
 ###  Local Variables:
787
 
 ###  mode: shell-script
788
 
 ###  End: