linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] trace-cmd: Fix bash completions for non specified commands
@ 2022-03-24  2:50 Steven Rostedt
  0 siblings, 0 replies; only message in thread
From: Steven Rostedt @ 2022-03-24  2:50 UTC (permalink / raw)
  To: Linux Trace Devel

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 --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()
-- 
2.35.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-03-24  2:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-24  2:50 [PATCH] trace-cmd: Fix bash completions for non specified commands Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).