public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Ulrich Mueller" <ulm@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/eselect:master commit in: libs/, /, bin/
Date: Sat,  6 Jul 2013 13:06:15 +0000 (UTC)	[thread overview]
Message-ID: <1373115946.3a412426d924310abb59311dd3cc1133eb1c6849.ulm@gentoo> (raw)

commit:     3a412426d924310abb59311dd3cc1133eb1c6849
Author:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Sat Jul  6 13:05:46 2013 +0000
Commit:     Ulrich Mueller <ulm <AT> gentoo <DOT> org>
CommitDate: Sat Jul  6 13:05:46 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/eselect.git;a=commit;h=3a412426

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.

---
 ChangeLog         | 7 +++++++
 bin/eselect.in    | 7 ++++---
 libs/core.bash.in | 4 ++--
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1809cfb..f6ea4ff 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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


             reply	other threads:[~2013-07-06 13:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-06 13:06 Ulrich Mueller [this message]
  -- strict thread matches above, loose matches on Subject: below --
2013-10-25 16:32 [gentoo-commits] proj/eselect:master commit in: libs/, /, bin/ Ulrich Müller
2013-10-22  8:19 Ulrich Müller
2013-01-13 13:10 Ulrich Mueller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1373115946.3a412426d924310abb59311dd3cc1133eb1c6849.ulm@gentoo \
    --to=ulm@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox