[ipxe-devel] Global script ignore error behavior (was: Re: testing 'smbios/product' variable)

Robin Smidsrød robin at smidsrod.no
Tue Nov 13 10:32:35 UTC 2012


On 12.11.2012 15:36, Michael Brown wrote:
> Scripts terminate when any command fails.  In your case, at least one of
> the "iseq" commands will (by definition) always fail, causing the script
> to terminate.  You need to use the "||" operator to prevent this from
> happening:
> 
>   iseq ${smbios/product} ${VMWARET} && set vmware 1 ||
>   iseq ${smbios/product} ${VBOXT} && set vbox 1 ||
> 
> I've updated http://ipxe.org/46022001 to include a note explaining this.

I guess this is yet another reason why that script-modifying behavior we
talked about on the GSoC Mentor Summit might be useful.

Your suggestion of using the shebang line to ignore exceptions,
something like this, seems smart:

#!ipxe --ignore-exceptions
#!ipxe --ignore-error
#!ipxe --continue-on-exception
#!ipxe --continue-on-error
#!ipxe --trap-exception
#!ipxe --trap-error

Not sure which alternative makes more sense. I think I'm leaning towards
--continue-on-error, possibly with -c as the short option.

Maybe we should look to what the unix shells use to signal this kind of
behavior.

As you mentioned, this behavior would be scoped to the script file in
question, and whenever another chain is executed, this global variable
is reset according to the shebang line of the loaded script. This
obviously means we'll have to save the previous value of the global
variable in case the newly loaded script exits back to the previous one.

-- Robin




More information about the ipxe-devel mailing list