Skip to content

Instantly share code, notes, and snippets.

@rawiriblundell
Created January 9, 2020 11:23
Show Gist options
  • Save rawiriblundell/22751e82476483a037926e0eb86fff5f to your computer and use it in GitHub Desktop.
Save rawiriblundell/22751e82476483a037926e0eb86fff5f to your computer and use it in GitHub Desktop.
A tiny function to silence commands and output their return code, useful for portability (e.g. where 'grep' might not have a '-q' arg on a classic unix)
get_rc() {
"${@}" >/dev/null 2>&1 && return "${?}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment