Forum Discussion

TeDZzz's avatar
TeDZzz
Icon for Nimbostratus rankNimbostratus
Oct 28, 2018

irule unlike TCL regarding the specification of the body of when and if

How does the irule snippet below work when the left curly brace that starts the body of the when and if are after a newline. In TCL, this would generate an error, but the irule editor accepts it.

when HTTP_REQUEST
{ 
    if { [HTTP::uri] starts_with "/m" or [HTTP::uri] starts_with "/v/" or [HTTP::uri] starts_with "/Z" or [HTTP::uri] starts_with "/p"}
    {
         do something            

1 Reply

  • It is by convention more than anything that TCL requires the grouping brace { to be on the same line as the object it's grouping for. But you can always use line continuation if this doesn't appeal to you.

    if { $var == 1 } \
    {
        log local0. "match"
    }
    

    I'd probably argue at this point that you've only made it more difficult to read.