shellutils 0.0.14 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
@@ -115,28 +115,33 @@ module ShellUtils
115
115
 
116
116
  def exec_cmd_and_clear_password(cmd)
117
117
  puts cmd
118
- PTY.spawn(cmd) do |r, w|
119
- w.flush
120
- w.sync = true
121
- w.flush
122
- if r.expect(/[Pp]assword.*:.*$/, 1)
118
+ begin
119
+ PTY.spawn(cmd) do |r, w|
123
120
  w.flush
124
- w.puts(get_sudo_pwd)
121
+ w.sync = true
125
122
  w.flush
126
- begin
123
+ if r.expect(/[Pp]assword.*:.*$/, 1)
124
+ w.flush
125
+ w.puts(get_sudo_pwd)
127
126
  w.flush
128
- if r.expect(/[Pp]assword.*:.*$/, 1)
129
- error("the sudo password is incorrect. password=#{get_sudo_pwd}\nPlease change the password ex) set_sudo_pwd PASSWORD")
127
+ begin
128
+ w.flush
129
+ if r.expect(/[Pp]assword.*:.*$/, 1)
130
+ error("the sudo password is incorrect. password=#{get_sudo_pwd}\nPlease change the password ex) set_sudo_pwd PASSWORD")
131
+ end
132
+ rescue
130
133
  end
131
- rescue
134
+ end
135
+ w.flush
136
+ begin
137
+ puts r.read
138
+ rescue Errno::EIO # GNU/Linux raises EIO.
139
+ rescue IOError
132
140
  end
133
141
  end
134
- w.flush
135
- begin
136
- puts r.read
137
- rescue Errno::EIO # GNU/Linux raises EIO.
138
- rescue IOError
139
- end
142
+ rescue Errno::EIO
143
+ # If the password prompt does not appear.
144
+ `#{cmd}`
140
145
  end
141
146
  end
142
147
 
@@ -1,3 +1,3 @@
1
1
  module Shellutils
2
- VERSION = "0.0.14"
2
+ VERSION = "0.0.15"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shellutils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: