comparison modules/stdlib/lib/puppet/parser/functions/shell_split.rb @ 478:adf6fe9bbc17

Update Puppet modules to latest versions
author IBBoard <dev@ibboard.co.uk>
date Thu, 29 Aug 2024 18:47:29 +0100
parents d9352a684e62
children
comparison
equal deleted inserted replaced
477:21f6add30502 478:adf6fe9bbc17
1 # frozen_string_literal: true
2
1 require 'shellwords' 3 require 'shellwords'
2 # 4 #
3 # shell_split.rb 5 # shell_split.rb
4 # 6 #
5 module Puppet::Parser::Functions 7 module Puppet::Parser::Functions
6 newfunction(:shell_split, :type => :rvalue, :doc => <<-DOC 8 newfunction(:shell_split, type: :rvalue, doc: <<-DOC
7 @summary 9 @summary
8 Splits a string into an array of tokens in the same way the Bourne shell does. 10 Splits a string into an array of tokens in the same way the Bourne shell does.
9 11
10 @return 12 @return
11 array of tokens 13 array of tokens
12 14
13 This function behaves the same as ruby's Shellwords.shellsplit() function 15 This function behaves the same as ruby's Shellwords.shellsplit() function
14 DOC 16 DOC
15 ) do |arguments| 17 ) do |arguments|
16
17 raise(Puppet::ParseError, "shell_split(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1 18 raise(Puppet::ParseError, "shell_split(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1
18 19
19 string = arguments[0].to_s 20 string = arguments[0].to_s
20 21
21 result = Shellwords.shellsplit(string) 22 result = Shellwords.shellsplit(string)