Skip to content

Instantly share code, notes, and snippets.

Embed
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 = STDIN.read 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
You can’t perform that action at this time.