Question #11261
closedDouble-ampersand is not an "empty template variable"
Description
While writing technique template (*.st), currently it is impossible to use "&&", e.g. in implementation of shell commands.
Writing something like
commands: plugin_exist:: "${rabbitmqpl} list -m -e ^${pluginName}$ | /bin/grep -q ${pluginName} && /bin/echo '+Enabled'"
leads to error in generating promises from such directive.
Looks like Rudder assumes that two ampersands are always quoting template varialbes. But "&&" is just "&&", not an empty template entry.
(And single ampersand may although be needed in shell scripting.)
On the opposite, the following code works ok:
commands: plugin_exist:: "${rabbitmqpl} list -m -e ^${pluginName}$ | /bin/grep -q ${pluginName} || /bin/echo '+notEnabled'"
(?) M.b. there is the way to correctly escape "&" to bypass it inside promise?
Updated by Benoît PECCATTE over 7 years ago
StringTemplate is use to process .st files and it considers the ampersand (&) to be a special character.
So it need to be escaped by and backslash (\).
This means you need to write \&\& for a double ampersand.
Updated by François ARMAND over 7 years ago
Dmitry, did you succeed in making that work?
Please also, don't hesitate to come to our #rudder irc channel on freenode. There is almost always someone able to help, and sometime, it is quicker than opening a ticket. There is a web client here: http://webchat.freenode.net/?randomnick=0&channels=rudder&prompt=1
Updated by François ARMAND about 7 years ago
- Severity set to Minor - inconvenience | misleading | easy workaround
- User visibility set to Operational - other Techniques | Technique editor | Rudder settings
- Priority changed from 0 to 32
Perhaps we could (actually should) do better documentation on that.
Updated by Vincent MEMBRÉ about 7 years ago
- Target version changed from 4.1.7 to 4.1.8
Updated by Vincent MEMBRÉ about 7 years ago
- Target version changed from 4.1.8 to 4.1.9
Updated by Dmitry Svyatogorov about 7 years ago
I'm planning to do the test tomorrow. Sorry for the long delay, it's because my work is generally sprint-based.
Updated by Vincent MEMBRÉ almost 7 years ago
- Target version changed from 4.1.9 to 4.1.10
- Priority changed from 32 to 31
Updated by Dmitry Svyatogorov almost 7 years ago
Recently we made new technique with back-slashed double ampersands "\&\&".
All works fine, it generates promises with "&&".
Thanks a lot :)
Updated by Benoît PECCATTE almost 7 years ago
- Tracker changed from Bug to Question
- Status changed from New to Resolved