Created
December 1, 2009 05:51
-
-
Save pat/246100 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# I want to check if Sphinx is installed on machines to auto-determine the | |
# version. This can be done via the following line of code: | |
`indexer`[/^Sphinx (\d\.\d\.\d)/, 1] | |
# But, if indexer doesn't exist, then we get an error sent to the shell by Ruby | |
# (though it's not caught by $stdout/$stderr, so I assume it's core Ruby being | |
# inconsistent). | |
# | |
# I don't want the error - I have code in place to let the user know that | |
# indexer isn't there. | |
# | |
# Attempted workarounds: | |
# * system('indexer') sends the output to STDOUT on failure, and straight to the | |
# shell on success. | |
# * `indexer 2>/dev/null` isn't Windows friendly. | |
# | |
# So, what do I want? Code that checks for the existence of indexer, and runs it | |
# for the version output if it is there, otherwise returns nil, without ever | |
# printing anything to shell/STDOUT/STDERR, and works on Windows as well as Unix | |
# systems. Any suggestions? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment