6 module Puppet::Parser::Functions
7 newfunction(:shell_join, :type => :rvalue, :doc => <<-DOC
8 Builds a command line string from the given array of strings. Each array item is escaped for Bourne shell. All items are
9 then joined together, with a single space in between.
11 This function behaves the same as ruby's Shellwords.shelljoin() function
15 raise(Puppet::ParseError, "shell_join(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1
19 raise Puppet::ParseError, "First argument is not an Array: #{array.inspect}" unless array.is_a?(Array)
21 # explicit conversion to string is required for ruby 1.9
22 array = array.map { |item| item.to_s }
23 result = Shellwords.shelljoin(array)
29 # vim: set ts=2 sw=2 et :