-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
serg/mtr-bash-completion enhancement #63
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,30 @@ | ||
_mtr_complete_testnames () | ||
{ | ||
dir=$1 | ||
[ -d $dir/t ] && dir=$dir/t | ||
testnames=$( cd $dir && echo *.test | sed -e 's/\.test\>//g' ) | ||
dir="$1" | ||
[ -d "$dir"/t ] && dir="$dir"/t | ||
testnames=$( cd "$dir" && echo *.test | sed -e 's/\.test\>//g' ) | ||
} | ||
_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) | ||
suites=$(find "$sourcetestdir"/suite "$sourcetestdir"/../{storage,plugin}/*/mysql-test -type d -exec find '{}' -maxdepth 1 -name '*.test' -print -quit \; | sed -E "s@^$sourcetestdir/(suite|\.\./storage|\.\./plugin)/@@"'; s@/mysql-test@@; s@(/t)?/[^/]+\.test$@@'|sort -u) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this sed -E "s@^$sourcetestdir/(suite|\.\./(storage|plugin)/mysql-test)/@@"'; s@(/t)?/[^/]+\.test$@@' |
||
} | ||
_mtr_complete() | ||
{ | ||
[ -x ./mtr ] || return | ||
[ -d main ] && main=main || main=. | ||
sourcetestdir=$(sed -n -e "/^chdir/s/[^']*'\(.*\)');$/\1/p" < "$1") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that works only for out-of-source |
||
cur=$2 | ||
prev=$3 | ||
case $prev:$cur in | ||
*:--*) | ||
opts=$( ./mtr --list ) | ||
opts=$( "$1" --list ) | ||
COMPREPLY=( $( compgen -W "$opts" -- $cur) ) | ||
;; | ||
*:main.*) | ||
_mtr_complete_testnames $main | ||
[ -d "${sourcetestdir}/main" ] && dir="${sourcetestdir}/main" || dir="${sourcetestdir}" | ||
_mtr_complete_testnames "$dir" | ||
COMPREPLY=( $( compgen -P ${cur%.*}. -W "$testnames" -- ${cur#*.}) ) | ||
;; | ||
*:?*.*) | ||
for dir in {../{storage,plugin}/*/mysql-test,suite}/${cur%.*}; do | ||
for dir in "${sourcetestdir}"/{suite,../{storage,plugin}/*/mysql-test}/${cur%.*}; do | ||
if [ -d $dir ]; then | ||
_mtr_complete_testnames $dir | ||
break | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you actually test it with a path that contains spaces? Or you've quoted paths just in case, without testing?