From b9279f5917a511c590f66fca9f7ab59de6964e6c Mon Sep 17 00:00:00 2001 From: Marian Krcmarik Date: Mon, 9 Mar 2015 20:56:25 +0100 Subject: [PATCH] Fix bash autocompletion of "rally task sla_check" Character "_" is used as delimiter of commands and their subcommands stored in bash array as keys, i.e. in form "task_sla_check". Current code splits it into an array based on delimiter "_" which would return array with three values - task, sla and check. The patch takes first value from the beginning to first "_" as command and the rest as its subcommand. Change-Id: I7d8c9b1eeb7c28ef24b0f2f366c6a18930282be5 Closes-bug: 1401180 --- etc/rally.bash_completion | 5 +++-- rally/cmd/cliutils.py | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/etc/rally.bash_completion b/etc/rally.bash_completion index 8bb8ef0fc3..565c8040ec 100644 --- a/etc/rally.bash_completion +++ b/etc/rally.bash_completion @@ -50,8 +50,9 @@ _rally() for OPT in ${!OPTS[*]} ; do - CMDSUB=(${OPT//_/ }) - SUBCOMMANDS[${CMDSUB[0]}]+="${CMDSUB[1]} " + CMD=${OPT%%_*} + CMDSUB=${OPT#*_} + SUBCOMMANDS[${CMD}]+="${CMDSUB} " done COMMANDS="${!SUBCOMMANDS[*]}" diff --git a/rally/cmd/cliutils.py b/rally/cmd/cliutils.py index 4740cbb411..6f645bc646 100644 --- a/rally/cmd/cliutils.py +++ b/rally/cmd/cliutils.py @@ -445,8 +445,9 @@ _rally() %(data)s for OPT in ${!OPTS[*]} ; do - CMDSUB=(${OPT//_/ }) - SUBCOMMANDS[${CMDSUB[0]}]+="${CMDSUB[1]} " + CMD=${OPT%%%%_*} + CMDSUB=${OPT#*_} + SUBCOMMANDS[${CMD}]+="${CMDSUB} " done COMMANDS="${!SUBCOMMANDS[*]}" @@ -489,4 +490,4 @@ complete -F _rally rally completion.append(""" OPTS["{cat}_{cmd}"]="{args}"\n""".format( cat=category, cmd=name, args=args)) - return bash_data % {"data": "".join(sorted(completion))} \ No newline at end of file + return bash_data % {"data": "".join(sorted(completion))}