iPXE discussion forum
iseq on a string with a space?? - Printable Version

+- iPXE discussion forum (https://forum.ipxe.org)
+-- Forum: iPXE user forums (/forumdisplay.php?fid=1)
+--- Forum: General (/forumdisplay.php?fid=2)
+--- Thread: iseq on a string with a space?? (/showthread.php?tid=7960)



iseq on a string with a space?? - robzr - 2016-02-11 21:15

On a Dell server, the ${manufacturer} variable is "Dell Inc.". I cannot figure out a way to do an iseq on this variable, I tried:

iseq ${manufacturer} Dell${}Inc.

But it always evaluates false. Using anything with a space, 'Dell Inc.', "Dell Inc.", Dell\ Inc., etc, always results in syntax error since it is parsed as two arguments.

Any recommendations?

Rob


RE: iseq on a string with a space?? - NiKiZe - 2016-02-11 21:28

(2016-02-11 21:15)robzr Wrote:  On a Dell server, the ${manufacturer} variable is "Dell Inc.". I cannot figure out a way to do an iseq on this variable, I tried:

iseq ${manufacturer} Dell${}Inc.

But it always evaluates false. Using anything with a space, 'Dell Inc.', "Dell Inc.", Dell\ Inc., etc, always results in syntax error since it is parsed as two arguments.

Any recommendations?

To create a variable that contains a space run
Code:
set sp:hex 20 && set sp ${sp:string}

Now you can run
Code:
iseq ${manufacturer} Dell${sp}Inc.

If it does not work, what is the output of echo ${manufacturer:hexhyp} ?


RE: iseq on a string with a space?? - robzr - 2016-02-11 22:01

(2016-02-11 21:28)NiKiZe Wrote:  
(2016-02-11 21:15)robzr Wrote:  On a Dell server, the ${manufacturer} variable is "Dell Inc.". I cannot figure out a way to do an iseq on this variable, I tried:

iseq ${manufacturer} Dell${}Inc.

But it always evaluates false. Using anything with a space, 'Dell Inc.', "Dell Inc.", Dell\ Inc., etc, always results in syntax error since it is parsed as two arguments.

Any recommendations?

To create a variable that contains a space run
Code:
set sp:hex 20 && set sp ${sp:string}

Now you can run
Code:
iseq ${manufacturer} Dell${sp}Inc.

If it does not work, what is the output of echo ${manufacturer:hexhyp} ?

That worked - thanks! I'm surprised the parser doesn't support at least a backslash escape at the least, must be a very lightweight routine.

Rob


RE: iseq on a string with a space?? - NiKiZe - 2016-02-11 22:05

(2016-02-11 22:01)robzr Wrote:  I'm surprised the parser doesn't support at least a backslash escape at the least, must be a very lightweight routine.

Implementing support for that would indeed be good, but since that would be a general part of the scripting the question is how many already existing scripts it would break for.