Add an example for fallback to sh

This commit is contained in:
Nobuyoshi Nakada 2024-03-01 02:34:39 +09:00
parent 5baee82c76
commit 9b75e5f085
No known key found for this signature in database
GPG Key ID: 3582D74E1FEE4465

View File

@ -64,6 +64,23 @@ describe :kernel_system, shared: true do
end
end
platform_is_not :windows do
before :each do
require 'tmpdir'
@shell_command = File.join(Dir.mktmpdir, "noshebang.cmd")
File.write(@shell_command, %[echo "$PATH"\n], perm: 0o700)
end
after :each do
File.unlink(@shell_command)
Dir.rmdir(File.dirname(@shell_command))
end
it "executes with `sh` if the command is executable but not binary and there is no shebang" do
-> { @object.system(@shell_command) }.should output_to_fd(ENV['PATH'] + "\n")
end
end
before :each do
ENV['TEST_SH_EXPANSION'] = 'foo'
@shell_var = '$TEST_SH_EXPANSION'