Forum Discussion
uni
Altostratus
Sep 13, 2007Preventing interpreting variable as TCL
I have an iRule which is parsing the each field in a URI query. I am getting an occasional problem with a TCL error if $parameter starts with "-", as the interpreter assumes it is an option to the split command. Is there some sort of quoting I can use to prevent this?
switch [string tolower [lindex [split $parameter "="] 0]] {
- hoolio
Cirrostratus
Can you add logging and reply with the TCL error? It seemed to work as expected in a simple test with a parameter and value that start with a hypher (or two hyphens):when RULE_INIT { set param_value "-par1=-val1" log local0. "\$param_value: $param_value" log local0. "\[split $param_value =\]: [split $param_value =]" log local0. "\[lindex \[split $param_value =\] 0\]: [lindex [split $param_value =] 0]" }
- To include dashes in your variables, you can enclose the variable in braces and will tell the interpretor to treat the enclosed value as a single entity.
switch [string tolower [lindex [split ${parameter} "="] 0]] {
- uni
Altostratus
For anyone who cares, the solution to this was to add "--" after the switch statement, to ensure it parses the next item as the test value rather than one of the command switches:switch -- [string tolower [lindex [split ${parameter} "="] 0]] {
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects