Skip to content

Instantly share code, notes, and snippets.

@zdennis
Created December 3, 2019 16:58
Show Gist options
  • Save zdennis/016fb9f446eeb7ff8fa599eb2d9cc4aa to your computer and use it in GitHub Desktop.
Save zdennis/016fb9f446eeb7ff8fa599eb2d9cc4aa to your computer and use it in GitHub Desktop.
Treat all arguments a command to be run.
#!/usr/bin/env ruby
MAX_RETRIES = 4
SLEEP=2
COMMAND=ARGV.join(' ')
count = 0
loop do
puts "Running: #{COMMAND.inspect}"
unless system(COMMAND)
abort "The command failed"
end
count += 1
if count == MAX_RETRIES
abort "The command passed #{count} times."
end
sleep 2
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment