[Asterisk-Users] Format of extensions.conf

Leif Madsen asterisk.leif.madsen at gmail.com
Mon Oct 24 21:52:24 MST 2005


On 10/24/05, David Tillman <photondave+asteriskusers at gmail.com> wrote:
> In my (inherited) extensions.conf I have some lines of the format:
>
>  exten => o,2,GotoIf($["foo${FROM_DID}" =
> "foo"]?from-pstn,s,1:from-pstn,${FROM_DID},1)
>
> and some lines like:
>
>  exten => s,1,GotoIf($[foo${ECID${CALLERIDNUM}} = foo]?4)
>
>
> Note the quotes around the "foo${FROM_DID}" and "foo" in the
> first, but the lack of quotes in the second.
>
> Are these syntacticly equivalent?
>
> In the first, is it just comparing to see if the string "foo" still equals
> "foo" after the vars are interpolated?

In the above examples, it appears as if they are basically doing the
same thing. In previous versions of Asterisk, the parser (apparently)
didn't deal with NULL strings too well (i.e. "") and may have become
confused. This caused a work around by appending "foo" or something
similar to the front of a string. Thus, if a string was NULL (blank),
then foo would equal foo, and you could consider the string null.

Now, as someone has also pointed out, using quotes around the string
is probably better form as it should handle spaces and such.

However, the need to place "foo" in the string should no longer be
necessary if you simple use the best practice is encapsulating your
strings with double quotes.

i.e., to check for a NULL value, you might use something like:

exten => s,1,GotoIf($[ "${CALLERIDNUM}" = "" ]?invalid_callerid:valid_callerid)

Note that in the above example I've assumed you have a named priority
called invalid_callerid and valid_callerid in your dialplan (which is
available in CVS HEAD, and the upcoming 1.2.x)

--
Leif Madsen - http://www.leifmadsen.com
http://www.asteriskdocs.org -- Co-Founder
http://www.oreilly.com/catalog/asterisk -- Co-Author



More information about the asterisk-users mailing list