[U-Boot] does u-boot automatically determine valid command abbreviations?

Robert P. J. Day rpjday at crashcourse.ca
Thu Jul 14 13:03:31 CEST 2016


  i just want to confirm that u-boot *automatically* determines the
valid prefix abbreviations for u-boot commands, correct? as in, there
is no registration or configuration to do that, it's done
automatically based on the commands that have been configured into
u-boot and whether a command abbreviation represents a unique prefix
for all configured commands, yes?

  i'm making that assumption based on this routine from
common/command.c:

  /* find command table entry for a command */
  cmd_tbl_t *find_cmd_tbl(const char *cmd, cmd_tbl_t *table, int table_len)
  {
  #ifdef CONFIG_CMDLINE
        cmd_tbl_t *cmdtp;
        cmd_tbl_t *cmdtp_temp = table;  /* Init value */
        const char *p;
        int len;
        int n_found = 0;

        if (!cmd)
                return NULL;
        /*
         * Some commands allow length modifiers (like "cp.b");
         * compare command name only until first dot.
         */
        len = ((p = strchr(cmd, '.')) == NULL) ? strlen (cmd) : (p - cmd);

        for (cmdtp = table; cmdtp != table + table_len; 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;
        }
  #endif /* CONFIG_CMDLINE */

        return NULL;    /* not found or ambiguous command */
  }

so am i reading that correctly that any unique prefix for configured
commands will work? i ask only because, recently, someone made the
claim in some u-boot instructions i'm reading:

  * Use “setenv” command instead of “set” for target boards.  u-boot
    source is not yet modified to alias “setenv” to “set”. Other
    commands like “printenv” and “saveenv” can still be called as
    “print” and “save”.

huh? why would someone have to "modify" the source to allow "set" to
be a valid abbreviation for "setenv"? (aside: these instructions mix
advice for both current and very old versions of u-boot, so maybe that
claim is only for very old versions.)

  anyway, clarifiation would be appreciated. thank you kindly.

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================


More information about the U-Boot mailing list