Skip to content

Instantly share code, notes, and snippets.

@aont
Created November 8, 2014 08:10
Show Gist options
  • Select an option

  • Save aont/03d81b7abdc558331740 to your computer and use it in GitHub Desktop.

Select an option

Save aont/03d81b7abdc558331740 to your computer and use it in GitHub Desktop.
loop
#!/usr/bin/ruby
require 'optparse'
Signal::trap("INT") do |signo|
exit
end
opt = OptionParser.new
wait_sec = 1
opt.on('-i wait', "wait second") do |wait_str|
wait_sec = wait_str.to_i
end
count = 0
opt.on('-c count', "loop count") do |count_str|
count = count_str.to_i
end
opt.order!(ARGV)
s= (ARGV.map do |arg| "\"#{arg.gsub("\"", "\\\"")}\"" end ).join(" ")
count_current = 0
while true
system(s)
count_current+=1
break if count>0 && count_current == count
sleep wait_sec
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment