[PATCH] trace-cmd: Fix bash completions for non specified commands

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Steven Rostedt (Google)" <rostedt@xxxxxxxxxxx>

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@xxxxxxxxxxx>
---
 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




[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux