mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 1/3] command: do not allow abbreviated commands anymore
Date: Mon, 27 Feb 2012 20:24:51 +0100	[thread overview]
Message-ID: <1330370693-1591-2-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1330370693-1591-1-git-send-email-s.hauer@pengutronix.de>

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@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


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2012-02-27 19:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-27 19:24 [PATCH] some binary space reduction Sascha Hauer
2012-02-27 19:24 ` Sascha Hauer [this message]
2012-02-27 19:24 ` [PATCH 2/3] ARM boot[zu]: return COMMAND_ERROR_USAGE instead of calling barebox_cmd_usage Sascha Hauer
2012-02-27 19:24 ` [PATCH 3/3] commands: remove struct command pointer from commands Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1330370693-1591-2-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox