[PATCH 1/3] command: do not allow abbreviated commands anymore

Sascha Hauer s.hauer at pengutronix.de
Mon Feb 27 14:24:51 EST 2012


abbreviated commands are derived from U-Boot and are only
partly useful. Noone expects from a shell to support this,
also we have tab completion. They also have some funny
side effects. For example we have a 'time' command. If this
command is not compiled in, the time command is interpreted
as an abbreviated version of the 'timeout' command. So remove
support for abbreviated commands and safe the binary space.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 common/command.c |   22 +++-------------------
 1 files changed, 3 insertions(+), 19 deletions(-)

diff --git a/common/command.c b/common/command.c
index de2c3a9..c9bab2a 100644
--- a/common/command.c
+++ b/common/command.c
@@ -159,26 +159,10 @@ EXPORT_SYMBOL(register_command);
 struct command *find_cmd (const char *cmd)
 {
 	struct command *cmdtp;
-	struct command *cmdtp_temp = &__barebox_cmd_start;	/*Init value */
-	int len;
-	int n_found = 0;
-	len = strlen (cmd);
 
-	cmdtp = list_entry(&command_list, struct command, list);
-
-	for_each_command(cmdtp) {
-		if (strncmp (cmd, cmdtp->name, len) == 0) {
-			if (len == strlen (cmdtp->name))
-				return cmdtp;		/* full match */
-
-			cmdtp_temp = cmdtp;		/* abbreviated command ? */
-			n_found++;
-		}
-	}
-
-	if (n_found == 1) {			/* exactly one match */
-		return cmdtp_temp;
-	}
+	for_each_command(cmdtp)
+		if (!strcmp(cmd, cmdtp->name))
+			return cmdtp;
 
 	return NULL;	/* not found or ambiguous command */
 }
-- 
1.7.9.1




More information about the barebox mailing list