[PATCH] ash: fix help builtin and tab completion of builtins

Ron Yorston via busybox <[email protected]>
Newsgroups gmane.linux.busybox
Message-ID <69886272.mhj7+HTZzj4TzMeM%[email protected]>
Commit 56143ea63 (ash: code shrink: eliminate pstrcmp1()) changed
the layout of struct builtincmd so the name member points to the
start of the name, not the flag in the first element of the string.
This broke the help builtin and tab completion of builtins.

Remove the unnecessary '+ 1' in ash_command_name() and helpcmd().

ash_command_name                                      92      91      -1
helpcmd                                              106     102      -4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-5)               Total: -5 bytes

Signed-off-by: Ron Yorston <[email protected]>
---
 shell/ash.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/shell/ash.c b/shell/ash.c
index 4f824e1b2..e88d07456 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -10855,7 +10855,7 @@ ash_command_name(int i)
 	int n;
 
 	if (/*i >= 0 &&*/ i < ARRAY_SIZE(builtintab))
-		return builtintab[i].name + 1;
+		return builtintab[i].name;
 	i -= ARRAY_SIZE(builtintab);
 
 	for (n = 0; n < CMDTABLESIZE; n++) {
@@ -14395,7 +14395,7 @@ helpcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
 		"------------------\n");
 	for (col = 0, i = 0; i < ARRAY_SIZE(builtintab); i++) {
 		col += out1fmt("%c%s", ((col == 0) ? '\t' : ' '),
-					builtintab[i].name + 1);
+					builtintab[i].name);
 		if (col > 60) {
 			out1fmt("\n");
 			col = 0;
-- 
2.53.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.