Skip to content

Commit

Permalink
Add an example for fallback to sh
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Mar 1, 2024
1 parent 5baee82 commit 9b75e5f
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions spec/ruby/core/kernel/system_spec.rb
Expand Up @@ -64,6 +64,23 @@
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'
Expand Down

0 comments on commit 9b75e5f

Please sign in to comment.