#!/usr/bin/env bash
#
# errcolor - run command, color its stderr stream in red and print its exit code
#
# usage: errcolor <command> [<args...>]

set -eu

status=0
"$@" 2> >(
  IFS=$(printf ' \n')
  while read -r line; do
    printf "\e[0;31m%s\e[m\n" "${line}"
  done
) || status="$?"
printf "\e[0;33mexit code: %d\e[m\n" "${status}"
