aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Müller <ulm@gentoo.org>2013-01-13 13:06:06 (GMT)
committerUlrich Müller <ulm@gentoo.org>2013-01-13 13:10:47 (GMT)
commit12e3ecb19d311b888abc118d806fee635602e3ee (patch)
tree372cb6b437662c738f87f152ec88f005791c7d59
parentWhitespace and quoting. (diff)
downloadeselect-12e3ecb19d311b888abc118d806fee635602e3ee.zip
eselect-12e3ecb19d311b888abc118d806fee635602e3ee.tar.gz
eselect-12e3ecb19d311b888abc118d806fee635602e3ee.tar.bz2
Restore stderr in die() function, bug 451150.
* bin/eselect.in (ESELECT_STDERR): Save stderr file descriptor. * libs/core.bash.in (die): Restore stderr, otherwise there would be no output if die was called while stderr is redirected. Fixes bug 451150. Thanks to Michał Górny <mgorny@gentoo.org>.
-rw-r--r--ChangeLog7
-rwxr-xr-xbin/eselect.in5
-rw-r--r--libs/core.bash.in5
3 files changed, 16 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 85e0b6e..c24a5fb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2013-01-13 Ulrich Müller <ulm@gentoo.org>
+
+ * bin/eselect.in (ESELECT_STDERR): Save stderr file descriptor.
+ * libs/core.bash.in (die): Restore stderr, otherwise there would
+ be no output if die was called while stderr is redirected.
+ Fixes bug 451150. Thanks to Michał Górny <mgorny@gentoo.org>.
+
2013-01-06 Ulrich Müller <ulm@gentoo.org>
* configure.ac: Update version to 1.3.4.
diff --git a/bin/eselect.in b/bin/eselect.in
index 3f99f95..8fd1589 100755
--- a/bin/eselect.in
+++ b/bin/eselect.in
@@ -55,6 +55,11 @@ IFS=$' \t\n'
shopt -s extglob
shopt -s expand_aliases
+# Save stderr file descriptor
+# exec {ESELECT_STDERR}>&2 # >=bash-4.1
+exec 3>&2
+ESELECT_STDERR=3
+
# Load core functions
source "${ESELECT_CORE_PATH}/core.bash" || exit 255
# Load necessary functions for the main script
diff --git a/libs/core.bash.in b/libs/core.bash.in
index 90b6621..fe174d1 100644
--- a/libs/core.bash.in
+++ b/libs/core.bash.in
@@ -32,6 +32,9 @@ check_do() {
die() {
local item funcname="" sourcefile="" lineno="" n e s="yes"
+ # Restore stderr if it was redirected
+ exec 2>&${ESELECT_STDERR}
+
# do we have a working write_error_msg?
if is_function "write_error_msg"; then
e="write_error_msg"
@@ -45,7 +48,7 @@ die() {
shift
fi
- $e "${@:-(no message)}"
+ $e "${@:-(no message)}" >&2
if [[ -n ${s} ]]; then
echo "Call stack:" >&2