Commit 89faeaf

mo <mo.khan@gmail.com>
2018-05-10 04:36:33
yield or reply but not both.
1 parent 15a7d7b
Changed files (1)
lib
lib/del/message.rb
@@ -15,16 +15,22 @@ module Del
 
     def execute_shell(command)
       command = Array(command).flatten.join(' ')
-      reply("Okay, I will run #{command}.")
+      reply("Okay, I will run '#{command}'.")
       success = false
       Open3.popen3(command) do |stdin, stdout, stderr, wait_thr|
         stdout.each_line do |line|
-          yield line if block_given?
-          reply("#{PREFIX} #{line}")
+          if block_given?
+            yield line
+          else
+            reply("#{PREFIX} #{line}")
+          end
         end
         stderr.each_line do |line|
-          yield line if block_given?
-          reply("#{PREFIX} #{line}")
+          if block_given?
+            yield line
+          else
+            reply("#{PREFIX} #{line}")
+          end
         end
         success = wait_thr.value.success?
       end