This file is indexed.

/usr/share/doc/ruby-session/examples/bash.rb is in ruby-session 3.1.0-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env ruby
$:.unshift '.', '..', 'lib', File.join('..','lib')

require 'session'


bash = Session::Bash.new


puts "======== ======== ======== ========"
puts "#1"
puts "======== ======== ======== ========"

stdout, stderr = bash.execute 'ls'

puts "STDOUT:\n#{ stdout }"
puts "STDERR:\n#{ stderr }"

puts "STATUS: #{ bash.status }"
puts "======== ======== ======== ========"


puts "======== ======== ======== ========"
puts "#2"
puts "======== ======== ======== ========"

bash.execute 'ls' do |stdout, stderr|
  puts "STDOUT:\n#{ stdout }"
  puts "STDERR:\n#{ stderr }"
end

puts "STATUS: #{ bash.status }"
puts "======== ======== ======== ========"


puts "======== ======== ======== ========"
puts "#3"
puts "======== ======== ======== ========"

stdout, stderr = '', ''
bash.execute 'ls', :stdout => stdout, :stderr => stderr

puts "STDOUT:\n#{ stdout }"
puts "STDERR:\n#{ stderr }"

puts "STATUS: #{ bash.status }"
puts "======== ======== ======== ========"


puts "======== ======== ======== ========"
puts "#4"
puts "======== ======== ======== ========"

bash.outproc = lambda{|out| puts "#{ out }"}
bash.errproc = lambda{|err| raise err}

bash.execute('while test 1; do echo 42; sleep 1; done') # => 42 ... 42 ... 42 
puts "======== ======== ======== ========"