Merge pull request #4776 from reitermarkus/system-command-with-spaces
Fix executable with spaces.
This commit is contained in:
commit
eddd864a7d
@ -119,7 +119,7 @@ class SystemCommand
|
|||||||
executable, *args = command
|
executable, *args = command
|
||||||
|
|
||||||
raw_stdin, raw_stdout, raw_stderr, raw_wait_thr =
|
raw_stdin, raw_stdout, raw_stderr, raw_wait_thr =
|
||||||
Open3.popen3(env, executable, *args, **options)
|
Open3.popen3(env, [executable, executable], *args, **options)
|
||||||
|
|
||||||
write_input_to(raw_stdin)
|
write_input_to(raw_stdin)
|
||||||
raw_stdin.close_write
|
raw_stdin.close_write
|
||||||
|
|||||||
@ -21,7 +21,7 @@ describe SystemCommand do
|
|||||||
it "includes the given variables explicitly" do
|
it "includes the given variables explicitly" do
|
||||||
expect(Open3)
|
expect(Open3)
|
||||||
.to receive(:popen3)
|
.to receive(:popen3)
|
||||||
.with(an_instance_of(Hash), "env", "A=1", "B=2", "C=3", "env", *env_args, {})
|
.with(an_instance_of(Hash), ["env", "env"], "A=1", "B=2", "C=3", "env", *env_args, {})
|
||||||
.and_call_original
|
.and_call_original
|
||||||
|
|
||||||
command.run!
|
command.run!
|
||||||
@ -46,7 +46,7 @@ describe SystemCommand do
|
|||||||
it "includes the given variables explicitly" do
|
it "includes the given variables explicitly" do
|
||||||
expect(Open3)
|
expect(Open3)
|
||||||
.to receive(:popen3)
|
.to receive(:popen3)
|
||||||
.with(an_instance_of(Hash), "/usr/bin/sudo", "-E", "--",
|
.with(an_instance_of(Hash), ["/usr/bin/sudo", "/usr/bin/sudo"], "-E", "--",
|
||||||
"env", "A=1", "B=2", "C=3", "env", *env_args, {})
|
"env", "A=1", "B=2", "C=3", "env", *env_args, {})
|
||||||
.and_wrap_original do |original_popen3, *_, &block|
|
.and_wrap_original do |original_popen3, *_, &block|
|
||||||
original_popen3.call("true", &block)
|
original_popen3.call("true", &block)
|
||||||
@ -227,5 +227,22 @@ describe SystemCommand do
|
|||||||
args: ["-c", 'printf "\r%s" "################### 27.6%" 1>&2']
|
args: ["-c", 'printf "\r%s" "################### 27.6%" 1>&2']
|
||||||
}.to output("\r################### 27.6%").to_stderr
|
}.to output("\r################### 27.6%").to_stderr
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "when given an executable with spaces and no arguments" do
|
||||||
|
let(:executable) { mktmpdir/"App Uninstaller" }
|
||||||
|
|
||||||
|
before(:each) do
|
||||||
|
executable.write <<~SH
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
true
|
||||||
|
SH
|
||||||
|
|
||||||
|
FileUtils.chmod "+x", executable
|
||||||
|
end
|
||||||
|
|
||||||
|
it "does not interpret the executable as a shell line" do
|
||||||
|
expect(system_command(executable)).to be_a_success
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user