[Home]

Summary:ASTERISK-09520: GotoIf doesn't seem to work in the h extension.
Reporter:Matthew Schumacher (akschu)Labels:
Date Opened:2007-05-25 12:48:43Date Closed:2011-06-07 14:02:51
Priority:MajorRegression?No
Status:Closed/CompleteComponents:Functions/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:Dial plan:

; figure out if we have new messages then set mwi
exten => h,1,GotoIf($["${VMBOX}" = "" ] ? 100 )
exten => h,2,Set(COUNT=${VMCOUNT(${VMBOX})})
exten => h,3,GotoIf( $[ "${COUNT}" != "0" ] ? 10 : 20)
exten => h,10,DeadAGI(mwi.agi,ON,${VMBOX})
exten => h,11,Goto(100)
exten => h,20,DeadAGI(mwi.agi,OFF,${VMBOX})
exten => h,100,NoOp()

Result when VMCOUNT = 0:

Executing [h@default:1] GotoIf("Zap/8-1", "0 ? 100 ") in new stack
Executing [h@default:2] Set("Zap/8-1", "COUNT=0") in new stack
Executing [h@default:3] GotoIf("Zap/8-1", " 0 ? 10 : 20") in new stack
Goto (default,h,10)
Executing [h@default:10] DeadAGI("Zap/8-1", "mwi.agi|ON|xxxxxxx") in new stack

Result when VMCOUNT = 1:

Executing [h@default:1] GotoIf("Zap/7-1", "0 ? 100 ") in new stack
Executing [h@default:2] Set("Zap/7-1", "COUNT=1") in new stack
Executing [h@default:3] GotoIf("Zap/7-1", " 1 ? 10 : 20") in new stack
Goto (default,h,10)
Executing [h@default:10] DeadAGI("Zap/7-1", "mwi.agi|ON|xxxxxxx") in new stack

As you can see, GotoIf() always forwards to the true extension regardless of the condition returned.  I've read everything I can and posted to the forums and can't come up with anything other than it's a bug.

The problem can be repeated every time.

****** ADDITIONAL INFORMATION ******

Platform:

Linux: Slackware 11.0
glibc-2.3.6
gcc version 3.4.6

This happens in 1.4.4 release and also in svn 1.4 revision 66207.
Comments:By: Jason Parker (jparker) 2007-05-29 11:04:58

Please try it without all of the extra spacing.  ie;

exten => h,3,GotoIf( $["${COUNT}" != "0"]?10:20)
instead of
exten => h,3,GotoIf( $[ "${COUNT}" != "0" ] ? 10 : 20)


What I believe is happening, is that it's considering " 0 " to be true, since it's being (correctly?) parsed as a non-zero string.