aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Müller <ulm@gentoo.org>2013-10-25 18:28:17 +0200
committerUlrich Müller <ulm@gentoo.org>2013-10-25 18:28:17 +0200
commita530e411f0cc50cf9598985fb03cf40ff85c69d7 (patch)
tree2f9e32850ecc9e8120d4c840c84aee245e805575
parentRearrange variables. (diff)
downloadeselect-a530e411f0cc50cf9598985fb03cf40ff85c69d7.tar.gz
eselect-a530e411f0cc50cf9598985fb03cf40ff85c69d7.tar.bz2
eselect-a530e411f0cc50cf9598985fb03cf40ff85c69d7.zip
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.
-rw-r--r--ChangeLog7
-rwxr-xr-xbin/eselect.in4
-rw-r--r--libs/output.bash.in41
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