[j-nsp] terminate endless loop in SLAX

Phil Shafer phil at juniper.net
Tue Jun 26 14:35:28 EDT 2018

Martin T writes:
>Thanks Phil! So in short, at the moment "terminate" statement inside
>the while loop works in a way that when "terminate" statement is
>executed, then immediately next iteration of while loop is started if
>while expression returns true and this will loop infinitely? If this
>while expression returns false, then terminate statement was the last
>thing processed by the script and script exits. At least based on my
>tests it seems to work like that.

Yes, which does inspire a reasonable (if ugly) workaround:

Bock % cat /tmp/foo.slax
version 1.2;

match / {
    mvar $working = true();

    <op-script-results> {
        while ($working) {
            set $working = false();
            terminate "doa";
Bock % slaxproc -E -g /tmp/foo.slax
<?xml version="1.0"?>
Bock %

Hope this helps.


More information about the juniper-nsp mailing list