Skip to content

Commit 3d5d645

Browse files
committed
Always pass subject to stdlib escape function
At the cost of one more function call, we gain in readability and what the docker::escape functions is more straightforward.
1 parent 3dd5a52 commit 3d5d645

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

lib/puppet/parser/functions/docker_run_flags.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
# frozen_string_literal: true
22

3-
require 'shellwords'
43
#
54
# docker_run_flags.rb
65
#
76
module Puppet::Parser::Functions
87
newfunction(:'docker::escape', type: :rvalue) do |args|
98
subject = args[0]
109

11-
if self['facts'] && self['facts']['os']['family'] == 'windows'
12-
call_function('powershell_escape', subject)
13-
else
14-
subject.shellescape
15-
end
10+
escape_function = if self['facts'] && self['facts']['os']['family'] == 'windows'
11+
'powershell_escape'
12+
else
13+
'shell_escape'
14+
end
15+
16+
call_function(escape_function, subject)
1617
end
1718

1819
# Transforms a hash into a string of docker flags

0 commit comments

Comments
 (0)