Skip to contentSkip to conversation

trace-cmd: Fix bash completions for non specified commands

PATCH New Steven Rostedt 1 participant 1 message Mar 24, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 trace-cmd: Fix bash completions for non specified commands

From: "Steven Rostedt (Google)" <[email protected]>

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
---
 tracecmd/trace-cmd.bash | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
tracecmd/trace-cmd.bash +5 -3
index 6639c1433678..66bd6f4bf2dd 100644
@@ -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()
Signature · 1 line
2.35.1