[j-nsp] Is it possible to pass apostrophe character(ASCII dec code 39) as an argument value to SLAX script?

Phil Shafer phil at juniper.net
Thu Jul 12 17:35:31 EDT 2018


Martin T writes:
>aren't you using grave accent("echo -e "\x60"") character? I was using
>"echo -e "\x27"" character.

Doh!  I read apostrophe (even named the script apos.slax) but my
brain turned into backtick.

Yes, this looks like a JUNOS bug:

root at box> op apos char "'"
''':(null):(2) Invalid expression
error: runtime error
error: Evaluating user parameter char failed

The underlaying slax library handles it correctly:

% slaxproc -E -n cs-examples/apos.slax -g -a char "'"
<?xml version="1.0"?>
<op-script-results>
  <output>got: '</output>
</op-script-results>

But it looks like this is explicitly handled in slaxproc.c:

            quote = strrchr(pvalue, '\"') ? '\'' : '\"';
            tvalue[0] = quote;
            memcpy(tvalue + 1, pvalue, plen);
            tvalue[plen + 1] = quote;
            tvalue[plen + 2] = '\0';

This logic doesn't appear in the JUNOS driver (/usr/libexec/ui/cscript).
I'll open a PR for this.

There is a limitation in XSLT that one can't mix strings with both
single and double quotes.  Strange but true.

Thanks,
 Phil


More information about the juniper-nsp mailing list