Skip to content

Commit 4e92e7b

Browse files
Merge pull request #265 from chef/rishichawda/handle-ruby-34-warnings
assign @stdout, @stderr and @process_status to mutable strings in preparation for ruby 4.0
2 parents 62cdb0b + 6e69321 commit 4e92e7b

File tree

3 files changed

+2
-5
lines changed

3 files changed

+2
-5
lines changed

lib/mixlib/shellout.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@ class ShellOut
170170
# cmd = Mixlib::ShellOut.new("apachectl", "start", :user => 'www', :env => nil, :cwd => '/tmp')
171171
# cmd.run_command # etc.
172172
def initialize(*command_args)
173-
@stdout, @stderr, @process_status = "", "", ""
173+
# Since ruby 4.0 will freeze string literals by default, we are assigning mutable strings here.
174+
@stdout, @stderr, @process_status = String.new(""), String.new(""), String.new("")
174175
@live_stdout = @live_stderr = nil
175176
@input = nil
176177
@log_level = :debug

lib/mixlib/shellout/windows/core_ext.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,6 @@ def destroy_environment_block(env_pointer)
447447

448448
def create_process_as_user(token, app, cmd, process_security,
449449
thread_security, inherit, creation_flags, env, cwd, startinfo, procinfo)
450-
451450
bool = CreateProcessAsUserW(
452451
token, # User token handle
453452
app, # App name
@@ -479,7 +478,6 @@ def create_process_as_user(token, app, cmd, process_security,
479478

480479
def create_process_with_logon(logon, domain, passwd, logon_flags, app, cmd,
481480
creation_flags, env, cwd, startinfo, procinfo)
482-
483481
bool = CreateProcessWithLogonW(
484482
logon, # User
485483
domain, # Domain
@@ -501,7 +499,6 @@ def create_process_with_logon(logon, domain, passwd, logon_flags, app, cmd,
501499

502500
def create_process(app, cmd, process_security, thread_security, inherit,
503501
creation_flags, env, cwd, startinfo, procinfo)
504-
505502
bool = CreateProcessW(
506503
app, # App name
507504
cmd, # Command line

spec/mixlib/shellout_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1613,4 +1613,3 @@ def ruby_wo_shell(code)
16131613
end
16141614
end
16151615
end
1616-

0 commit comments

Comments
 (0)