[ovs-dev] [PATCH] ovs-command-completion: Avoid using negative subscript.

Alex Wang alexw at nicira.com
Sun Feb 1 17:03:38 UTC 2015


Negative subscript causes error in bash version 4.1.2(1)-release
(x86_64-redhat-linux-gnu).  This commit fixes it.

Signed-off-by: Alex Wang <alexw at nicira.com>
---
 utilities/ovs-command-compgen.bash |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/utilities/ovs-command-compgen.bash b/utilities/ovs-command-compgen.bash
index fa3f1e6..b9df527 100755
--- a/utilities/ovs-command-compgen.bash
+++ b/utilities/ovs-command-compgen.bash
@@ -600,8 +600,8 @@ if [ "$1" = "debug" ]; then
     # next argument which is not input yet.  This hack is for
     # compromising the fact that bash cannot take unquoted
     # empty argument.
-    if [ "${COMP_WORDS[-1]}" = "TAB" ]; then
-        COMP_WORDS[${#COMP_WORDS[@]}-1]=""
+    if [ "${COMP_WORDS[$COMP_CWORD]}" = "TAB" ]; then
+        COMP_WORDS[$COMP_CWORD]=""
     fi
 
     _ovs_command_complete "debug"
-- 
1.7.9.5




More information about the dev mailing list