diff options
author | Ulrich Müller <ulm@gentoo.org> | 2013-07-06 15:05:46 +0200 |
---|---|---|
committer | Ulrich Müller <ulm@gentoo.org> | 2013-07-06 15:05:46 +0200 |
commit | 3a412426d924310abb59311dd3cc1133eb1c6849 (patch) | |
tree | 63151e69c4945eae8ac9238fb522a2e92309d38b | |
parent | Update copyright notice. (diff) | |
download | eselect-3a412426d924310abb59311dd3cc1133eb1c6849.tar.gz eselect-3a412426d924310abb59311dd3cc1133eb1c6849.tar.bz2 eselect-3a412426d924310abb59311dd3cc1133eb1c6849.zip |
Work around bash crashing on Darwin, bug 475284.
* bin/eselect.in: Save stderr only in bash 4.1 or later, where
automatically assigned file descriptors are available. Using a
fixed descriptor makes bash crash on Darwin, bug 475284.
* libs/core.bash.in (die): Test for saved file descriptor.
-rw-r--r-- | ChangeLog | 7 | ||||
-rwxr-xr-x | bin/eselect.in | 7 | ||||
-rw-r--r-- | libs/core.bash.in | 4 |
3 files changed, 13 insertions, 5 deletions
@@ -1,3 +1,10 @@ +2013-07-06 Ulrich Müller <ulm@gentoo.org> + + * bin/eselect.in: Save stderr only in bash 4.1 or later, where + automatically assigned file descriptors are available. Using a + fixed descriptor makes bash crash on Darwin, bug 475284. + * libs/core.bash.in (die): Test for saved file descriptor. + 2013-07-04 Ulrich Müller <ulm@gentoo.org> * misc/eselect-mode.el: New file, editing mode for Emacs, diff --git a/bin/eselect.in b/bin/eselect.in index 8fd1589..ea632ce 100755 --- a/bin/eselect.in +++ b/bin/eselect.in @@ -56,9 +56,10 @@ shopt -s extglob shopt -s expand_aliases # Save stderr file descriptor -# exec {ESELECT_STDERR}>&2 # >=bash-4.1 -exec 3>&2 -ESELECT_STDERR=3 +if (( BASH_VERSINFO[0] == 4 && BASH_VERSINFO[1] >= 1 || BASH_VERSINFO[0] > 4 )) +then + exec {ESELECT_STDERR}>&2 # >=bash-4.1 +fi # Load core functions source "${ESELECT_CORE_PATH}/core.bash" || exit 255 diff --git a/libs/core.bash.in b/libs/core.bash.in index fe174d1..2a682ce 100644 --- a/libs/core.bash.in +++ b/libs/core.bash.in @@ -32,8 +32,8 @@ check_do() { die() { local item funcname="" sourcefile="" lineno="" n e s="yes" - # Restore stderr if it was redirected - exec 2>&${ESELECT_STDERR} + # Restore stderr + [[ -n ${ESELECT_STDERR} ]] && exec 2>&${ESELECT_STDERR} # do we have a working write_error_msg? if is_function "write_error_msg"; then |