Skip to content

Instantly share code, notes, and snippets.

Created November 22, 2010 20:03
What would you like to do?
Check for piped STDIN in ruby shell scripts without prompting
# body will be set ONLY if data is piped in, and will not
# prompt the user for STDIN otherwise.
require 'fcntl'
body = if STDIN.fcntl(Fcntl::F_GETFL, 0) == 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment