[ipxe-devel] [GitHub] Add 'equals' command [ipxe/ipxe GH-4]

Michael Brown mbrown at fensystems.co.uk
Fri Apr 8 03:10:23 UTC 2011


On Thursday 07 Apr 2011 18:41:02 Greg Jednaszewski wrote:
> > There is already a viable way to force a trailing space on "echo":
> >
> >    set spc:hex 20
> >    echo -n Prompt:${spc} && read answer
> 
> I'll test this out.  I think that will work for me.

I just thought of an even simpler way:

  echo -n Prompt: ${} && read answer

I have updated http://ipxe.org/cmd/read to include this hint.

> > For "equals": I think that "iseq" or "isequal" would probably be a better
> > name, for consistency with "isset".  What do you think?
> 
> That sounds good.  I'll go with iseq and resubmit with the echo -n space
>  change taken out.

Thanks!  Two other points regarding the actual code:

+    return strcmp ( argv[1], argv[2] );

argv[1] and argv[2] should be argv[optind] and argv[optind+1], for consistency 
with other commands (and in case parse_options() ever allows a generic option 
that (unlike "--help") doesn't prevent the command from executing).

.exec() methods return a status code, so you need something like

   return ( ( strcmp ( argv[optind], argv[optind+1] ) == 0 ) ? 0 : -ERANGE );

ERANGE isn't a particularly great choice; take your pick of errors listed in 
include/errno.h if you think there's a better one.

Michael



More information about the ipxe-devel mailing list