Writing a function that should display errors on terminal and save them to stderr
die () {
echo "$(tput setaf 1) ERROR: $*. Aborting... $(tput sgr 0)" > &2
exit 1
}
unfortunately this will generate
syntax error near unexpected token `&'
` echo "$(tput setaf 1) ERROR: $*. Aborting... $(tput sgr 0)" > &2 '
I understood it was because of the tput but I am not able to figure out why.
I do not really care to have colors in my stderr but I would like to keep them on the display.
Redirection to stderr is done by >&2
- with no whitespace.