Forum Discussion
TCL error "bad option" with minus character
Hi,
We have an iRule that tries to match user agents against a datagroup - this has been working fine for a while however recently we've seen a bunch of TCL errors show up, that I believe are due to the user-agent beginning with a minus character:
- bad option "-1'": must be -all, -index, -element, -name, or -value while executing "class match [string tolower [HTTP::header "User-Agent"]] contains mobileUserAgents"
It seems like TCL is expanding the string and interpreting it as an option rather than just a string used to match against a datagroup. What would be the best way to mitigate against this and use it as just a string? Can we wrap double quotes around it or do we have to sanitise it further, such as looking for a "-" at the beginning and stripping it out before doing the class match?
Thanks in advance
james
2 Replies
- hoolio
Cirrostratus
Hi James,
You can use -- to terminate the options for the class command:
class match -- [string tolower [HTTP::header "User-Agent"]] contains mobileUserAgents
https://devcentral.f5.com/wiki/iRules.class.ashx
-- Terminates option processing (useful if the or begins with a hyphen).
Aaron - JamesS_40157
Nimbostratus
Ah, I did not know that, thanks hoolio!
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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