Created
September 28, 2008 15:06
-
-
Save mguterl/13466 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WIN32 = %r/djgpp|(cyg|ms|bcc)win|mingw/ =~ RUBY_PLATFORM unless defined? WIN32 | |
DEV_NULL = WIN32 ? 'NUL:' : '/dev/null' | |
def quiet( &block ) | |
io = [STDOUT.dup, STDERR.dup] | |
STDOUT.reopen DEV_NULL | |
STDERR.reopen DEV_NULL | |
block.call | |
ensure | |
STDOUT.reopen io.first | |
STDERR.reopen io.last | |
$stdout, $stderr = STDOUT, STDERR | |
end | |
DIFF = if WIN32 then 'diff.exe' | |
else | |
if quiet {system "gdiff", __FILE__, __FILE__} then 'gdiff' | |
else 'diff' end | |
end unless defined? DIFF | |
SUDO = if WIN32 then '' | |
else | |
if quiet {system 'which sudo'} then 'sudo' | |
else '' end | |
end | |
puts "foo" # this does not print under JRuby |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment