Skip to content

Commit 3ebeb1d

Browse files
peffgitster
authored andcommitted
generate-cmdlist.sh: do not shell out to "sed"
Replace the "sed" invocation in get_synopsis() with a pure-shell version. This speeds up generate-cmdlist.sh significantly. Compared to HEAD~ (old) and "master" we are, according to hyperfine(1): 'sh generate-cmdlist.sh command-list.txt' ran 12.69 ± 5.01 times faster than 'sh generate-cmdlist.sh.old command-list.txt' 18.34 ± 3.03 times faster than 'sh generate-cmdlist.sh.master command-list.txt' Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 8d5be8b commit 3ebeb1d

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

generate-cmdlist.sh

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,6 @@ category_list () {
1717
LC_ALL=C sort -u
1818
}
1919

20-
get_synopsis () {
21-
sed -n '
22-
/^NAME/,/'"$1"'/H
23-
${
24-
x
25-
s/.*'"$1"' - \(.*\)/N_("\1")/
26-
p
27-
}' "Documentation/$1.txt"
28-
}
29-
3020
define_categories () {
3121
echo
3222
echo "/* Command categories */"
@@ -61,7 +51,18 @@ print_command_list () {
6151
command_list "$1" |
6252
while read cmd rest
6353
do
64-
printf " { \"$cmd\", $(get_synopsis $cmd), 0"
54+
synopsis=
55+
while read line
56+
do
57+
case "$line" in
58+
"$cmd - "*)
59+
synopsis=${line#$cmd - }
60+
break
61+
;;
62+
esac
63+
done <"Documentation/$cmd.txt"
64+
65+
printf '\t{ "%s", N_("%s"), 0' "$cmd" "$synopsis"
6566
printf " | CAT_%s" $rest
6667
echo " },"
6768
done

0 commit comments

Comments
 (0)