diff mbox series

trace-cmd: Fix bash completions for non specified commands

Message ID 20220323225016.3a3a7034@gandalf.local.home (mailing list archive)
State Accepted
Commit ec198af190425711b87fff2ef0dc4c965daf411a
Headers show
Series trace-cmd: Fix bash completions for non specified commands | expand

Commit Message

Steven Rostedt March 24, 2022, 2:50 a.m. UTC
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

For trace-cmd commands that are not specifically specified by the bash
completion script, allow to see files after the commands. There's a bug in
the test that returns if there are options, and does not jump to the file
listing if there is any option even if the user does not specify one, and
wants a file instead.

Also make a reference to $cur more consistent with its other references,
which is ${cur}

Fixes: 431f1a03f59cb trace-cmd: Fix bash completion on directory names
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 tracecmd/trace-cmd.bash | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/tracecmd/trace-cmd.bash b/tracecmd/trace-cmd.bash
index 6639c1433678..66bd6f4bf2dd 100644
--- a/tracecmd/trace-cmd.bash
+++ b/tracecmd/trace-cmd.bash
@@ -52,7 +52,7 @@  cmd_options()
 				 sed -e 's/ *\(-[^ ]*\).*/\1/')
     COMPREPLY=( $(compgen -W "${cmds}" -- "${cur}") )
     if [ ${#COMPREPLY[@]} -eq 0 ]; then
-	__show_files "$cur"
+	__show_files "${cur}"
     fi
 }
 
@@ -276,10 +276,12 @@  __show_command_options()
 		done
 	    fi
 	    COMPREPLY=( $(compgen -W "${opts}" -- "$cur"))
-	    return 0
+	    break
 	fi
     done
-    __show_files "$cur"
+    if [ ${#COMPREPLY[@]} -eq 0 ]; then
+	__show_files "${cur}"
+    fi
 }
 
 _trace_cmd_complete()