All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] does u-boot automatically determine valid command abbreviations?
@ 2016-07-14 11:03 Robert P. J. Day
  2016-07-14 19:42 ` Wolfgang Denk
  0 siblings, 1 reply; 3+ messages in thread
From: Robert P. J. Day @ 2016-07-14 11:03 UTC (permalink / raw)
  To: u-boot


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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot] does u-boot automatically determine valid command abbreviations?
  2016-07-14 11:03 [U-Boot] does u-boot automatically determine valid command abbreviations? Robert P. J. Day
@ 2016-07-14 19:42 ` Wolfgang Denk
  2016-07-14 19:49   ` Robert P. J. Day
  0 siblings, 1 reply; 3+ messages in thread
From: Wolfgang Denk @ 2016-07-14 19:42 UTC (permalink / raw)
  To: u-boot

Dear Robert,

In message <alpine.LFD.2.20.1607140645350.11114@localhost.localdomain> you wrote:
> 
>   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?

Correct.

> 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.)

I cannot comment on the "modify" part, as it makes no sense to me.
But I can comment on the background of the story:  In the early days
of U-Boot, actually for ages, it has been more or less standard habit
to most experienced users to just write "set" instead of "setenv", as
this was sufficient to uniquely identify that command.   This was also
used in a ton of scripts.

Then, at some point, a new command (can't remember which one it was;
eventually "setdcr"?) was added, and "set" was no longer a unique
prefix, old habits and a ton of scripts broke.

So habits had to be adjusted to type "sete" instead.  So were
scripts.  The word was fine again.

You guess what happened?  Right - then the command "setexpr" was
added, and again "sete" was no longer unique.

Moral of the stroy: use "env set" ;-)

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Work 8 hours, sleep 8 hours; but not the same 8 hours.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot] does u-boot automatically determine valid command abbreviations?
  2016-07-14 19:42 ` Wolfgang Denk
@ 2016-07-14 19:49   ` Robert P. J. Day
  0 siblings, 0 replies; 3+ messages in thread
From: Robert P. J. Day @ 2016-07-14 19:49 UTC (permalink / raw)
  To: u-boot

On Thu, 14 Jul 2016, Wolfgang Denk wrote:

> Dear Robert,

... snip ...

> Then, at some point, a new command (can't remember which one it was;
> eventually "setdcr"?) was added, and "set" was no longer a unique
> prefix, old habits and a ton of scripts broke.
>
> So habits had to be adjusted to type "sete" instead.  So were
> scripts.  The word was fine again.
>
> You guess what happened?  Right - then the command "setexpr" was
> added, and again "sete" was no longer unique.
>
> Moral of the stroy: use "env set" ;-)

  i'm embarrassed to admit i didn't even know the "env" command
existed. learn something new every day.

rday

-- 

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

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-07-14 19:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-14 11:03 [U-Boot] does u-boot automatically determine valid command abbreviations? Robert P. J. Day
2016-07-14 19:42 ` Wolfgang Denk
2016-07-14 19:49   ` Robert P. J. Day

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.