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

Greg Jednaszewski jednaszewski at gmail.com
Fri Apr 8 18:07:09 UTC 2011


Hi,
On Apr 7, 2011, at 11:10 PM, Michael Brown wrote:

> 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 oin f errors listed in 
> include/errno.h if you think there's a better one.

I made these changes in https://github.com/gjednaszewski/ipxe/commit/82aba048ca1364c1f980d9ad4f445ed5c331e8dc

I can submit a new pull request, or some other method, whatever works best for you.  I'm pretty new to github and git in general, so I don't know what all the options are.

Thanks,
Greg

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ipxe.org/pipermail/ipxe-devel/attachments/20110408/f72aee8c/attachment.htm>


More information about the ipxe-devel mailing list