What's the point of this:

abort() {
  { if [ "$#" -eq 0 ]; then cat -
    else echo "rbenv: $*"
  } >&2
  exit 1


1 Answer 1


If there are zero arguments provided to the function ("$#" -eq 0), then read from a preceeding pipe (cat -) instead, and redirect any output from this block to srderr (>&2).

This allows them to things like abort "shell integration not enabled... or

  { rbenv---version
  } | abort

and if any errors are encountered in doing so (e.g. the pipe provided no output and there were no arguments), those will also be surfaced to the user.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .