# ansi formatting function (\033[<code>m)
# 0: reset, 1: bold, 4: underline, 22: no bold, 24: no underline, 31: red, 33: yellow
s_printf() {
  [ $# -gt 0 ] || return
  IFS=";" printf "\033[%sm" "$*"
}
# if stdout is not a terminal ignore all formatting
[ -t 1 ] || s_printf() { :; }

safe_printf() {
  # if stdout is not a terminal ignore all formatting
  if test -t 1; then
    # ansi formatting function (\033[<code>m)
    # 0: reset, 1: bold, 4: underline, 22: no bold, 24: no underline, 31: red, 33: yellow
    [ $# -gt 0 ] || return
    IFS=";" printf "\033[%sm" "$*"
  else
    { :; }
  fi
}
