updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / bash4-completion-git / scp-complete.patch
blobc4dd20c6fcde710d60e586a319106da34cd70f20
1 diff -aur build-old/bash_completion build-new/bash_completion
2 --- build-old/bash_completion 2009-08-23 18:38:19.000000000 +1100
3 +++ build-new/bash_completion 2009-08-26 00:04:19.000000000 +1100
4 @@ -246,33 +246,29 @@
5 # for things like scp where we want to return host:path and not only path.
6 _get_cword()
8 - if [[ "${#COMP_WORDS[COMP_CWORD]}" -eq 0 ]] || [[ "$COMP_POINT" == "${#COMP_LINE}" ]]; then
9 - printf "%s" "${COMP_WORDS[COMP_CWORD]}"
10 - else
11 - local i
12 - local cur="$COMP_LINE"
13 - local index="$COMP_POINT"
14 - for (( i = 0; i <= COMP_CWORD; ++i )); do
15 - while [[ "${#cur}" -ge ${#COMP_WORDS[i]} ]] && [[ "${cur:0:${#COMP_WORDS[i]}}" != "${COMP_WORDS[i]}" ]]; do
16 - cur="${cur:1}"
17 - index="$(( index - 1 ))"
18 - done
19 - if [[ "$i" -lt "$COMP_CWORD" ]]; then
20 - local old_size="${#cur}"
21 - cur="${cur#${COMP_WORDS[i]}}"
22 - local new_size="${#cur}"
23 - index="$(( index - old_size + new_size ))"
24 - fi
25 + local i
26 + local LC_CTYPE=C
27 + local WORDBREAKS=${COMP_WORDBREAKS}
28 + if [ -n $1 ]; then
29 + for (( i=0; i<${#1}; ++i )); do
30 + local char=${1:$i:1}
31 + WORDBREAKS=${WORDBREAKS//$char/}
32 done
34 - if [[ "${COMP_WORDS[COMP_CWORD]:0:${#cur}}" != "$cur" ]]; then
35 - # We messed up! At least return the whole word so things
36 - # keep working
37 - printf "%s" "${COMP_WORDS[COMP_CWORD]}"
38 - else
39 - printf "%s" "${cur:0:$index}"
40 - fi
42 + local cur=${COMP_LINE:0:$COMP_POINT}
43 + local tmp="${cur}"
44 + local word_start=`expr "$tmp" : '.*['"${WORDBREAKS}"']'`
45 + while [ "$word_start" -ge 2 ]; do
46 + local char=${cur:$(( $word_start - 2 )):1}
47 + if [ "$char" != "\\" ]; then
48 + break
49 + fi
50 + tmp=${COMP_LINE:0:$(( $word_start - 2 ))}
51 + word_start=`expr "$tmp" : '.*['"${WORDBREAKS}"']'`
52 + done
54 + cur=${cur:$word_start}
55 + echo "$cur"
58 # This function performs file and directory completion. It's better than
59 Only in build-new: debian