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
3 changed files with 28 additions and 3 deletions

View File

@@ -240,6 +240,12 @@ exec_login_shell() {
execute_with_perl
execute_sh_with_posix_env
exec "$login_shell" "-l"
printf "%s\n" "Could not execute the shell $login_shell as a login shell" > /dev/stderr
if [ -e /dev/stderr ]; then
printf "%s\n" "Could not execute the shell $login_shell as a login shell" > /dev/stderr
elif [ -e /dev/fd/2 ]; then
printf "%s\n" "Could not execute the shell $login_shell as a login shell" > /dev/fd/2
else
printf "%s\n" "Could not execute the shell $login_shell as a login shell"
fi
exec "$login_shell"
}

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() {

View File

@@ -6,7 +6,16 @@
{ \unalias command; \unset -f command; } >/dev/null 2>&1
die() { printf "\033[31m%s\033[m\n\r" "$*" > /dev/stderr; 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
exit 1;
}
exec_kitty() {
[ -n "$kitty_exe" ] && exec "$kitty_exe" "$@"