cancel
Showing results for 
Search instead for 
Did you mean: 

using curly braces "{" or "}" in a comment in an iRule

M_Afifi
Altostratus
Altostratus

Hi All,

 

I notice that if you use curly braces in a comment inside an iRule, the the BIGIP system count for it in the parsing process and this can lead to parsing error or it may case the iRule to function unexpectedly.

 

I think this behavior needs to be fixed.

 

Example:

 

If you type the below iRule, the GUI will generate parsing error:

 

when HTTP_REQUEST {     # This is a comment }   }

 

In the other hand, below iRule will be accepted by GUI:

 

when HTTP_REQUEST {     # This is a comment }

 Thanks.

4 REPLIES 4

You can use '\" backslash escape character if needed.

 

 

https://devcentral.f5.com/s/articles/irules-optimization-101-04-delimiters-braces-brackets-quotes-and-more

M_Afifi
Altostratus
Altostratus

Hi Nikoolayy1,

 

Yes i get that.

 

but don't you agree when its in a comment it should be ignored by the parser??

 

 

But you can reference variables in the comments , so I think this is why you get the ability to execute things like $variable in the comments but some things like " { " , " $ " etc. need escape character.

crodriguez
F5 Employee
F5 Employee

The sensitivity to whitespace is inherent in the Tcl language itself, and is not restricted to its use in BIG-IP iRules. When we teach iRules in our customer-facing training, one of the first things we point out is how impactful whitespace is on interpretation. The presence of whitespace delineates the potential start of something new, like a new command or a new positional parameter or a new operand. In other programming languages, command terminator characters (like ";") are required to delineate the end of a command. But not in Tcl. Every piece of whitespace has potential relevance, which is why special grouping characters, such as brackets and curly braces (to name but two) are also important. They are used to indicate the start or end of a series of grouped strings that contain whitespace. But this syntax is part of the language and something you simply must get used to when writing Tcl "programs."