* [gentoo-commits] proj/eselect:master commit in: libs/, /, bin/
@ 2013-01-13 13:10 Ulrich Mueller
0 siblings, 0 replies; 4+ messages in thread
From: Ulrich Mueller @ 2013-01-13 13:10 UTC (permalink / raw
To: gentoo-commits
commit: 12e3ecb19d311b888abc118d806fee635602e3ee
Author: Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 13 13:06:06 2013 +0000
Commit: Ulrich Mueller <ulm <AT> gentoo <DOT> org>
CommitDate: Sun Jan 13 13:10:47 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/eselect.git;a=commit;h=12e3ecb1
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 <AT> gentoo.org>.
---
ChangeLog | 7 +++++++
bin/eselect.in | 5 +++++
libs/core.bash.in | 5 ++++-
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [gentoo-commits] proj/eselect:master commit in: libs/, /, bin/
@ 2013-07-06 13:06 Ulrich Mueller
0 siblings, 0 replies; 4+ messages in thread
From: Ulrich Mueller @ 2013-07-06 13:06 UTC (permalink / raw
To: gentoo-commits
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [gentoo-commits] proj/eselect:master commit in: libs/, /, bin/
@ 2013-10-22 8:19 Ulrich Müller
0 siblings, 0 replies; 4+ messages in thread
From: Ulrich Müller @ 2013-10-22 8:19 UTC (permalink / raw
To: gentoo-commits
commit: a1de32ca76ee2dc24961f52b38c9c0f3cd51eb03
Author: Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Mon Oct 21 20:35:23 2013 +0000
Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Mon Oct 21 20:35:23 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/eselect.git;a=commit;h=a1de32ca
Move es_find_module function to core library.
* bin/eselect.in (es_find_module): Move function to core library.
* libs/core.bash.in (find_module): Rename and simplify.
---
ChangeLog | 5 +++++
bin/eselect.in | 15 ---------------
libs/core.bash.in | 15 ++++++++++++++-
3 files changed, 19 insertions(+), 16 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index edb8af3..7436537 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-10-21 Ulrich Müller <ulm@gentoo.org>
+
+ * bin/eselect.in (es_find_module): Move function to core library.
+ * libs/core.bash.in (find_module): Rename and simplify.
+
2013-09-18 Ulrich Müller <ulm@gentoo.org>
* misc/eselect-mode.el (eselect-mode-keywords-package-manager):
diff --git a/bin/eselect.in b/bin/eselect.in
index ea632ce..e50fa8e 100755
--- a/bin/eselect.in
+++ b/bin/eselect.in
@@ -70,21 +70,6 @@ inherit manip output path-manipulation tests
# it, don't ask...
trap 'echo "exiting" >&2; exit 250' 15
-# es_find_module foo
-# Find and echo the filename of the foo module. If there's no foo module,
-# die.
-es_find_module() {
- local modname="$1" modpath="" modfile=""
- [[ -z ${modname} ]] && die "Usage: ${FUNCNAME} <module>"
- for modpath in "${ESELECT_MODULES_PATH[@]}"; do
- [[ -f ${modpath}/${modname}.eselect ]] && break
- done
-
- modfile="${modpath}/${modname}.eselect"
- [[ -r ${modfile} ]] || die -q "Can't load module ${modname}"
- echo ${modfile}
-}
-
# es_do_usage
# Display eselect usage
es_do_usage() {
diff --git a/libs/core.bash.in b/libs/core.bash.in
index 2a682ce..64dbede 100644
--- a/libs/core.bash.in
+++ b/libs/core.bash.in
@@ -65,6 +65,19 @@ die() {
exit 249
}
+# find_module module PRIVATE
+# Find module and echo its filename. Die if module doesn't exist.
+find_module() {
+ local modname=$1 modpath
+ for modpath in "${ESELECT_MODULES_PATH[@]}"; do
+ if [[ -f ${modpath}/${modname}.eselect ]]; then
+ echo "${modpath}/${modname}.eselect"
+ return
+ fi
+ done
+ die -q "Can't load module ${modname}"
+}
+
# do_action action args...
# Load and do 'action' with the specified args
do_action() {
@@ -78,7 +91,7 @@ do_action() {
[[ ${ESELECT_BINARY_NAME##*/} != "${ESELECT_PROGRAM_NAME}" ]] \
&& ESELECT_COMMAND="${ESELECT_BINARY_NAME##*/}"
- modfile=$( es_find_module "${action}" )
+ modfile=$(find_module "${action}")
(
source "$ESELECT_DEFAULT_ACTIONS" 2>/dev/null \
|| die "Couldn't source ${ESELECT_DEFAULT_ACTIONS}"
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [gentoo-commits] proj/eselect:master commit in: libs/, /, bin/
@ 2013-10-25 16:32 Ulrich Müller
0 siblings, 0 replies; 4+ messages in thread
From: Ulrich Müller @ 2013-10-25 16:32 UTC (permalink / raw
To: gentoo-commits
commit: a530e411f0cc50cf9598985fb03cf40ff85c69d7
Author: Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Fri Oct 25 16:28:17 2013 +0000
Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Fri Oct 25 16:28:17 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/eselect.git;a=commit;h=a530e411
Function 'colours' accepts an argument. Remove 'nocolours'.
* libs/output.bash.in (colours): Accept an argument and handle
both enabling and disabling of colour output.
(nocolours): Remove function.
* bin/eselect.in: Call 'colours' with appropriate argument.
---
ChangeLog | 7 +++++++
bin/eselect.in | 4 ++--
libs/output.bash.in | 41 ++++++++++++++++++++---------------------
3 files changed, 29 insertions(+), 23 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index f06969f..59a9ce1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2013-10-25 Ulrich Müller <ulm@gentoo.org>
+
+ * libs/output.bash.in (colours): Accept an argument and handle
+ both enabling and disabling of colour output.
+ (nocolours): Remove function.
+ * bin/eselect.in: Call 'colours' with appropriate argument.
+
2013-10-22 Ulrich Müller <ulm@gentoo.org>
* bin/eselect.in (es_do_list_options, es_do_list_modules):
diff --git a/bin/eselect.in b/bin/eselect.in
index fd570df..b3b7c9e 100755
--- a/bin/eselect.in
+++ b/bin/eselect.in
@@ -159,10 +159,10 @@ fi
# enable colour output and get width of terminal iff stdout is a tty
if [[ -t 1 ]]; then
- if [[ ${colour} = no ]]; then nocolours; else colours; fi
+ colours ${colour:-yes}
init_columns
else
- if [[ ${colour} = yes ]]; then colours; else nocolours; fi
+ colours ${colour:-no}
fi
unset colour
diff --git a/libs/output.bash.in b/libs/output.bash.in
index bf29721..5c79c53 100644
--- a/libs/output.bash.in
+++ b/libs/output.bash.in
@@ -15,28 +15,27 @@
# You should have received a copy of the GNU General Public License along with
# eselect. If not, see <http://www.gnu.org/licenses/>.
-# Colours
colours() {
- COLOUR_NORMAL=$(tput sgr0)
- COLOUR_BOLD=$(tput bold)
- COLOUR_HI=$(tput setaf 4)${COLOUR_BOLD} # blue
- COLOUR_WARN=$(tput setaf 1)${COLOUR_BOLD} # red
- COLOUR_ERROR=${COLOUR_WARN}
- COLOUR_LIST_HEADER=$(tput setaf 2)${COLOUR_BOLD} # green
- COLOUR_LIST_LEFT=${COLOUR_BOLD}
- COLOUR_LIST_RIGHT=${COLOUR_NORMAL}
-}
-
-# disable all colours
-nocolours() {
- COLOUR_NORMAL=""
- COLOUR_BOLD=""
- COLOUR_HI=""
- COLOUR_WARN=""
- COLOUR_ERROR=""
- COLOUR_LIST_HEADER=""
- COLOUR_LIST_LEFT=""
- COLOUR_LIST_RIGHT=""
+ if [[ $1 != n* ]]; then
+ COLOUR_NORMAL=$(tput sgr0)
+ COLOUR_BOLD=$(tput bold)
+ COLOUR_HI=$(tput setaf 4)${COLOUR_BOLD} # blue
+ COLOUR_WARN=$(tput setaf 1)${COLOUR_BOLD} # red
+ COLOUR_ERROR=${COLOUR_WARN}
+ COLOUR_LIST_HEADER=$(tput setaf 2)${COLOUR_BOLD} # green
+ COLOUR_LIST_LEFT=${COLOUR_BOLD}
+ COLOUR_LIST_RIGHT=${COLOUR_NORMAL}
+ else
+ # disable all colours
+ COLOUR_NORMAL=""
+ COLOUR_BOLD=""
+ COLOUR_HI=""
+ COLOUR_WARN=""
+ COLOUR_ERROR=""
+ COLOUR_LIST_HEADER=""
+ COLOUR_LIST_LEFT=""
+ COLOUR_LIST_RIGHT=""
+ fi
}
# set output mode to $1
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-10-25 16:33 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-22 8:19 [gentoo-commits] proj/eselect:master commit in: libs/, /, bin/ Ulrich Müller
-- strict thread matches above, loose matches on Subject: below --
2013-10-25 16:32 Ulrich Müller
2013-07-06 13:06 Ulrich Mueller
2013-01-13 13:10 Ulrich Mueller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox