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 /test/data | |
| 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 'test/data')
| -rw-r--r-- | test/data/snippets/ifexpression.pp | 12 | ||||
| -rw-r--r-- | test/data/snippets/ifexpression.rb | 6 |
2 files changed, 12 insertions, 6 deletions
diff --git a/test/data/snippets/ifexpression.pp b/test/data/snippets/ifexpression.pp new file mode 100644 index 000000000..29a637291 --- /dev/null +++ b/test/data/snippets/ifexpression.pp @@ -0,0 +1,12 @@ +$one = 1 +$two = 2 + +if ($one < $two) and (($two < 3) or ($two == 2)) { + notice("True!") +} + +if "test regex" =~ /(.*) regex/ { + file { + "/tmp/${1}iftest": ensure => file, mode => 0755 + } +} diff --git a/test/data/snippets/ifexpression.rb b/test/data/snippets/ifexpression.rb deleted file mode 100644 index eea3b855b..000000000 --- a/test/data/snippets/ifexpression.rb +++ /dev/null @@ -1,6 +0,0 @@ -$one = 1 -$two = 2 - -if ($one < $two) and (($two < 3) or ($two == 2)) { - notice("True!") -} |
