diff options
Diffstat (limited to 'code/environments/production/modules/stdlib/lib/puppet/parser/functions/shell_split.rb')
-rw-r--r-- | code/environments/production/modules/stdlib/lib/puppet/parser/functions/shell_split.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/code/environments/production/modules/stdlib/lib/puppet/parser/functions/shell_split.rb b/code/environments/production/modules/stdlib/lib/puppet/parser/functions/shell_split.rb new file mode 100644 index 0000000..9dcf958 --- /dev/null +++ b/code/environments/production/modules/stdlib/lib/puppet/parser/functions/shell_split.rb @@ -0,0 +1,23 @@ +require 'shellwords' +# +# shell_split.rb +# +module Puppet::Parser::Functions + newfunction(:shell_split, :type => :rvalue, :doc => <<-DOC + Splits a string into an array of tokens in the same way the Bourne shell does. + + This function behaves the same as ruby's Shellwords.shellsplit() function + DOC + ) do |arguments| + + raise(Puppet::ParseError, "shell_split(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1 + + string = arguments[0].to_s + + result = Shellwords.shellsplit(string) + + return result + end +end + +# vim: set ts=2 sw=2 et : |