google.golang.org/grpc@v1.72.2/scripts/common.sh (about)

     1  #!/bin/bash
     2  
     3  fail_on_output() {
     4    tee /dev/stderr | not read
     5  }
     6  
     7  # not makes sure the command passed to it does not exit with a return code of 0.
     8  not() {
     9    # This is required instead of the earlier (! $COMMAND) because subshells and
    10    # pipefail don't work the same on Darwin as in Linux.
    11    ! "$@"
    12  }
    13  
    14  # noret_grep will return 0 if zero or more lines were selected, and >1 if an
    15  # error occurred. Suppresses grep's return code of 1 when there are no matches
    16  # (for eg, empty file).
    17  noret_grep() {
    18    grep "$@" || [[ $? == 1 ]]
    19  }
    20  
    21  die() {
    22    echo "$@" >&2
    23    exit 1
    24  }