summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2024-03-01 02:34:39 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2024-03-01 13:56:52 +0900
commit9b75e5f08561437e42887dc19742ab186c52cc43 (patch)
treee5039eca14078b3bc7feb1345ffdd9d04002336b /spec
parent5baee82c766308294d21e8167af43dc01346eb76 (diff)
Add an example for fallback to sh
Diffstat (limited to 'spec')
-rw-r--r--spec/ruby/core/kernel/system_spec.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/spec/ruby/core/kernel/system_spec.rb b/spec/ruby/core/kernel/system_spec.rb
index 9671a650cc..9bc03924dd 100644
--- a/spec/ruby/core/kernel/system_spec.rb
+++ b/spec/ruby/core/kernel/system_spec.rb
@@ -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'