From 4cfa04ff98742cc010c5175e2f74aa40be5c7ee1 Mon Sep 17 00:00:00 2001 From: Ng Zhi An Date: Wed, 20 May 2020 00:11:29 +0000 Subject: [PATCH] Fix extra spaces in git cl completion The commands come from the output of git cl -h, which then goes through an sed filter, matching on the ANSI escape sequence for green and reset. This ends up having extra spaces, since the output aligns the subcommands based on the longest subcommand. For shorter commands like archive, it becomes "archive ". So, tweak the sed regex to only capture the part without the whitespaces. Change-Id: I80a84f142520478547895f85def68331575fdd72 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2209582 Reviewed-by: Edward Lesmes Commit-Queue: Zhi An Ng --- git_cl_completion.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git_cl_completion.sh b/git_cl_completion.sh index 86de6a5a9..8feb66aff 100755 --- a/git_cl_completion.sh +++ b/git_cl_completion.sh @@ -19,7 +19,7 @@ # Parses commands from git cl -h. __git_cl_commands () { - git cl -h 2> /dev/null | sed -n 's/^\s*\x1b\[32m\(.*\)\x1b\[39m.*$/\1/p' + git cl -h 2> /dev/null | sed -n 's/^\s*\x1b\[32m\(\S\+\)\s*\x1b\[39m.*$/\1/p' } # Caches variables in __git_cl_all_commands.