iPXE discussion forum
Using "||" as a string literal? - Printable Version

+- iPXE discussion forum (https://forum.ipxe.org)
+-- Forum: iPXE user forums (/forumdisplay.php?fid=1)
+--- Forum: General (/forumdisplay.php?fid=2)
+--- Thread: Using "||" as a string literal? (/showthread.php?tid=11124)



Using "||" as a string literal? - myxal - 2018-04-05 13:23

Is there a way to put a string containing "||" into a variable, and then using said variable in a kernel command?

This doesn't work - I can see in /proc/cmdline that the ocs_postrun is cut off at the double-pipe, while cmd_netdev is still included (so I shouldn't be hitting some limit, AFAICT)
Code:
...
set cmd_postrun       ocs_postrun=" (cat error.log || echo success) | nc -l -p 4444"
...
kernel ${clonezilla-url} ${cmd_common} ${cmd_postrun} ${cmd_netdev}

EDIT: It turns out bash doesn't mind if its own double-pipe isn't surrounded with spaces, so I'll probably resolve my issue by removing them. Still, it would be nice to know if the literal usage is somehow possible.


RE: Using "||" as a string literal? - mcb30 - 2018-04-05 14:30

(2018-04-05 13:23)myxal Wrote:  Is there a way to put a string containing "||" into a variable, and then using said variable in a kernel command?

Yes. There's no general purpose character escaping mechanism (e.g. a backslash) in iPXE, but you can hack around it using e.g.

Code:
set pipe |
set pipes ${pipe}${pipe}

and then use "${pipes}" in place of "||".

Michael