[gPXE-devel] [PATCH] [script] Control flow using if and goto
Stefan Hajnoczi
stefanha at gmail.com
Mon Mar 15 02:36:56 EDT 2010
On Sun, Mar 14, 2010 at 7:05 PM, Shao Miller
<Shao.Miller at yrdsb.edu.on.ca> wrote:
> #!gpxe
> set space:hex 20
> set colon:string :
> set foo:string foo
> set mylabel:hex ${colon:hex}:${space:hex}:${foo:hex}
> echo Do some stuff
> if ${some-condition} goto ${foo:string}
> goto end
> ${mylabel:string}
> echo Got to ${foo:string}
> : end
>
> I wanted to confirm that this patch's implementation of ': label' could
> never establish a "foo" label due to the expansion and could never output
> "Got to foo" regardless of some-condition. Is that so? If so, does it
> matter? Might anyone wish to dynamically generate labels for some reason?
It will not detect ${mylabel:string} because it just scans the script
for ': <label>'. It also doesn't handle whitespace like the script
grammar normally does, so " : label" will not be detected. A
solution to both limitations is to call into the system() code that
splits a command line into an argument vector and performs expansions.
I think dynamic labels are not that useful. If a dynamic label is in
a fixed position, like in the example above, then there is no real
reason to make it dynamic. On the other hand, dynamic labels in a
loop also don't make sense. I can't think of an essential use of
dynamic labels.
Stefan
More information about the gPXE-devel
mailing list