diff options
| author | Brice Figureau <brice-puppet@daysofwonder.com> | 2009-07-28 19:13:54 +0200 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2009-08-01 11:15:29 +1000 |
| commit | ef68967f2b72e609a9d69e53771a61fd9f522149 (patch) | |
| tree | b9e8baa5a45d31f03fa4fae83cb0160a71957dd9 /lib/puppet/parser/grammar.ra | |
| parent | 17e62b1ec806815abea909291df1e591a825c375 (diff) | |
| download | puppet-ef68967f2b72e609a9d69e53771a61fd9f522149.tar.gz puppet-ef68967f2b72e609a9d69e53771a61fd9f522149.tar.xz puppet-ef68967f2b72e609a9d69e53771a61fd9f522149.zip | |
Fix #2033 - Allow regexp in if expression
This changeset introduces regexp in if expression with the use of the
=~ (match) and !~ (not match) operator.
Usage:
if $uname =~ /Linux|Debian/ {
...
}
Moreover this patch creates ephemeral variables ($0 to $9) in the current
scope which contains the regex captures:
if $uname =~ /(Linux|Debian)/ {
notice("this is a $1 system")
}
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'lib/puppet/parser/grammar.ra')
| -rw-r--r-- | lib/puppet/parser/grammar.ra | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/puppet/parser/grammar.ra b/lib/puppet/parser/grammar.ra index 68acf35aa..2040ee868 100644 --- a/lib/puppet/parser/grammar.ra +++ b/lib/puppet/parser/grammar.ra @@ -488,6 +488,12 @@ else: # nothing # per operator :-( expression: rvalue + | expression MATCH regex { + result = ast AST::MatchOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] +} + | expression NOMATCH regex { + result = ast AST::MatchOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] +} | expression PLUS expression { result = ast AST::ArithmeticOperator, :operator => val[1][:value], :lval => val[0], :rval => val[2] } |
