rubysh 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -32,22 +32,25 @@ module Rubysh
32
32
 
33
33
  def prepare!(runner)
34
34
  tempfile = Tempfile.new('buffer')
35
+ tempfile_read_only = File.open(tempfile.path, 'r')
36
+
35
37
  tempfile.delete
36
38
  tempfile.write(@literal)
37
39
  tempfile.flush
38
40
  tempfile.rewind
41
+ tempfile.close
39
42
 
40
- Util.set_cloexec(tempfile)
43
+ Util.set_cloexec(tempfile_read_only)
41
44
 
42
45
  state = state(runner)
43
- state[:tempfile] = tempfile
44
- state[:redirect] = Redirect.new(@fd, '<', tempfile)
46
+ state[:tempfile] = tempfile_read_only
47
+ state[:redirect] = Redirect.new(@fd, '<', tempfile_read_only)
45
48
  end
46
49
 
47
50
  def stringify
48
51
  fd = Util.to_fileno(@fd)
49
52
  beginning = fd == 0 ? '' : fd.to_s
50
- "#{beginning}<<< #{@literal.inspect}"
53
+ "#{beginning}<<< (#{@literal.bytesize} bytes)"
51
54
  end
52
55
 
53
56
  def to_s
@@ -1,3 +1,3 @@
1
1
  module Rubysh
2
- VERSION = '0.0.9'
2
+ VERSION = '0.0.10'
3
3
  end
@@ -11,6 +11,23 @@ module RubyshTest::Functional
11
11
  output = result.read(:stdout)
12
12
  assert_equal('test', output)
13
13
  end
14
+
15
+ it 'stdin is read-only' do
16
+ cmd = Rubysh(
17
+ 'ruby', '-e', '
18
+ i = IO.new(0)
19
+ begin
20
+ i.write("hi")
21
+ rescue IOError => e
22
+ raise "Bad error: #{e}" unless e.message == "not opened for writing"
23
+ else
24
+ raise "Perfectly writable FD 0"
25
+ end
26
+ ', Rubysh.<<< 'test')
27
+ result = cmd.run
28
+
29
+ assert_equal(0, result.exitstatus)
30
+ end
14
31
  end
15
32
  end
16
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubysh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -138,7 +138,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
138
138
  version: '0'
139
139
  segments:
140
140
  - 0
141
- hash: 3714832706588225343
141
+ hash: 1275881591566036262
142
142
  required_rubygems_version: !ruby/object:Gem::Requirement
143
143
  none: false
144
144
  requirements:
@@ -147,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
147
  version: '0'
148
148
  segments:
149
149
  - 0
150
- hash: 3714832706588225343
150
+ hash: 1275881591566036262
151
151
  requirements: []
152
152
  rubyforge_project:
153
153
  rubygems_version: 1.8.23