Problem with dialplan, gosub and arguments

Hi *,
I have a small problem with a subroutine call (gosub). Here is an example:

exten => s,n,Gosub(sub-connectedline-info,s,1(${QOrigName},${QOrigNum}))

If the variable QorigName contains a text with a comma the subroutine is called with three arguments (instead of two).

How can I pass a text with comma in a variable as argument?
Asterisk is at 18.16.0.

Thanks in advance
Karsten

That’s basically because the dialplan interpreter is, basically, a text macro processor, so the Gosub sees what gets logged at verbosity 3.

I generally avoided anything needing quoting, as there is a lot of ad hoc parsing, and I’m never sure how they will be handled, but you could try double quotes. You might find you have to explicitly strip them. Otherwise you would need to use something like REPLACE, to change the , into something safe.

Hi david551,
thanks a lot. I now use double quotes in the call to gosub and do a REPLACE for the quotes in the subroutine.

Best regards,
Karsten

Hate string-substitution languages. Hate, hate, hate.

In POSIX shell syntax, special characters and word-splitting happens before the substitution of (quoted) variable values, not after. Even unquoted variable values only undergo word-splitting; any special characters they might contain, like redirection symbols etc, do not get their special interpretation.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.