Dont assume /dev/stderr exists

Fixes #6671
This commit is contained in:
Kovid Goyal 2023-10-04 06:26:56 +05:30
parent 5008b89804
commit fd12c5a1e0
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
3 changed files with 28 additions and 3 deletions

View file

@ -14,7 +14,17 @@ cleanup_on_bootstrap_exit() {
tdir=""
}
die() { printf "\033[31m%s\033[m\n\r" "$*" > /dev/stderr; cleanup_on_bootstrap_exit; exit 1; }
die() {
if [ -e /dev/stderr ]; then
printf "\033[31m%s\033[m\n\r" "$*" > /dev/stderr;
elif [ -e /dev/fd/2 ]; then
printf "\033[31m%s\033[m\n\r" "$*" > /dev/fd/2;
else
printf "\033[31m%s\033[m\n\r" "$*";
fi
cleanup_on_bootstrap_exit;
exit 1;
}
python_detected="0"
detect_python() {