X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=3rdparty%2Fmodules%2Fstdlib%2Flib%2Fpuppet%2Fparser%2Ffunctions%2Fshell_split.rb;fp=3rdparty%2Fmodules%2Fstdlib%2Flib%2Fpuppet%2Fparser%2Ffunctions%2Fshell_split.rb;h=09e6e78ce12ed3a405b365cf769e8519c29614e1;hb=6963202b4b62c2816655ac9532521b018fdf83bd;hp=0000000000000000000000000000000000000000;hpb=a69999e580f8b3abd12446c2d6ad59e517651813;p=mirror%2Fdsa-puppet.git diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/shell_split.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/shell_split.rb new file mode 100644 index 000000000..09e6e78ce --- /dev/null +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/shell_split.rb @@ -0,0 +1,25 @@ +# +# shell_split.rb +# + +require 'shellwords' + +module Puppet::Parser::Functions + newfunction(:shell_split, :type => :rvalue, :doc => <<-EOS +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 + EOS + ) 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 :