-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmtr-bash-completion.sh
More file actions
51 lines (51 loc) · 1.39 KB
/
Copy pathmtr-bash-completion.sh
File metadata and controls
51 lines (51 loc) · 1.39 KB
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
_mtr_complete_testnames ()
{
dir=$1
[ -d $dir/t ] && dir=$dir/t
testnames+=$( cd $dir && echo *.test | sed -e 's/\.test\>//g' )
testnames+=' '
}
_mtr_all_suites ()
{
suites=$(find suite ../{storage,plugin}/*/mysql-test -type d -exec find '{}' -maxdepth 1 -name '*.test' -print -quit \; | sed -E 's@/(t/)?[^/]+$@@; s@^(suite|.*/mysql-test)/@@'|sort -u)
}
_mtr_complete()
{
[ -x ./mtr ] || return
[ -d main ] && main=main || main=.
cur=$2
prev=$3
testnames=
case $prev:$cur in
*:--*)
opts=$( ./mtr --list )
COMPREPLY=( $( compgen -W "$opts" -- $cur) )
;;
*:main.*)
_mtr_complete_testnames $main
COMPREPLY=( $( compgen -P ${cur%.*}. -W "$testnames" -- ${cur#*.}) )
;;
*:?*.*)
for dir in {../{storage,plugin}/*/mysql-test,suite}/${cur%.*}; do
if [ -d $dir ]; then
_mtr_complete_testnames $dir
fi
done
COMPREPLY=( $( compgen -P ${cur%.*}. -W "$testnames" -- ${cur#*.}) )
;;
--suite:*)
_mtr_all_suites
compopt -o nospace
COMPREPLY=( $( compgen -S , -W "$suites" -- ${cur##*,}) )
local prefix=
[[ $cur == *,* ]] && prefix=${cur%,*},
[[ ${#COMPREPLY[@]} == 1 ]] && COMPREPLY=( $prefix$COMPREPLY )
;;
*)
_mtr_all_suites
compopt -o nospace
COMPREPLY=( $( compgen -S . -W "$suites" -- $cur) )
;;
esac
}
complete -F _mtr_complete mtr