summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Müller <ulm@gentoo.org>2013-03-09 13:32:31 +0100
committerUlrich Müller <ulm@gentoo.org>2013-03-09 13:34:54 +0100
commitc42f31849a70163a7364ed92eca5a2577f7010af (patch)
tree51ab99b244f22c6bb3c44ad0ce7b262a55af400b
parentRemove unneccesary quoting. (diff)
downloademacs-tools-c42f31849a70163a7364ed92eca5a2577f7010af.tar.gz
emacs-tools-c42f31849a70163a7364ed92eca5a2577f7010af.tar.bz2
emacs-tools-c42f31849a70163a7364ed92eca5a2577f7010af.zip
New --colour option.
* emacs-updater (OPTIONS): New long option --colour=<yes|no|auto>, compatible with the same option in eselect. Spelling --color is recognised too. (COLOUR): Variable renamed from NOCOLOUR. (usage): Update help text. * emacs-updater.8: Describe --colour option, drop --nocolour.
-rw-r--r--ChangeLog7
-rwxr-xr-xemacs-updater32
-rw-r--r--emacs-updater.818
3 files changed, 44 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index a17828a..1ba2684 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2013-03-09 Ulrich Müller <ulm@gentoo.org>
+ * emacs-updater (OPTIONS): New long option --colour=<yes|no|auto>,
+ compatible with the same option in eselect. Spelling --color is
+ recognised too.
+ (COLOUR): Variable renamed from NOCOLOUR.
+ (usage): Update help text.
+ * emacs-updater.8: Describe --colour option, drop --nocolour.
+
* emacs-updater: Remove unneccesary quoting.
2012-10-11 Ulrich Müller <ulm@gentoo.org>
diff --git a/emacs-updater b/emacs-updater
index ac42692..68c4ac3 100755
--- a/emacs-updater
+++ b/emacs-updater
@@ -19,9 +19,9 @@ PM_EXTRAOPTS=( )
# Other default variable settings
BATCH=
+COLOUR=
EXACT=
MAJOR=
-NOCOLOUR=
ORPHANS=
PRETEND=
@@ -41,11 +41,14 @@ usage() {
X byte-compiled Elisp files
X (default: sitedir,rebuild)
X -b, --batch batch mode, don't ask any questions
+ X --color MODE, --colour=MODE
+ X control colour output. MODE is 'yes', 'no',
+ X or 'auto'. For 'auto', colour is enabled
+ X if standard output is to a terminal
+ X (default: auto)
X -e, --exact match exact versions when remerging packages
X -m, --major use only the major version when comparing
X Emacs version numbers
- X -n, --nocolour, --nocolor
- X disable colour in output
X -o, --orphans list orphan files (implies '--action all')
X -p, --pretend don't actually emerge packages
X -P, --package-manager PM
@@ -104,8 +107,8 @@ pm_auto() {
# Read in all command-line options and force English output
OPTIONS=$(LC_ALL=C getopt -o a:behmnopP: \
- --long action:,batch,exact,help,major,nocolour,nocolor,orphans,pretend \
- --long package-manager:,package-manager-command:,version \
+ --long action:,batch,color:,colour:,nocolor,nocolour,exact,help,major \
+ --long orphans,pretend,package-manager:,package-manager-command:,version \
-n 'emacs-updater' -- "$@")
[ $? -eq 0 ] || usage 1
@@ -121,7 +124,19 @@ do
-m|--major) MAJOR="true"; shift ;;
-o|--orphans) ORPHANS="true"; ACTIONS="all"; shift ;;
-p|--pretend) PRETEND="true"; shift ;;
- -n|--nocolour|--nocolor) NOCOLOUR="true"; shift ;;
+ --color|--colour)
+ case $2 in
+ yes|y|always|force) COLOUR="yes" ;;
+ no|n|never|none) COLOUR="no" ;;
+ auto|tty|if-tty) COLOUR="" ;;
+ *)
+ echo "Invalid argument for '$1' option"
+ usage 20
+ ;;
+ esac
+ shift 2
+ ;;
+ -n|--nocolor|--nocolour) COLOUR="no"; shift ;; # legacy option
-a|--action)
ACTIONS=
for action in ${2/,/ }; do
@@ -164,9 +179,8 @@ do
esac
done
-# Only set colours if output is not redirected or the --nocolour
-# option is not set
-if [ -t 1 ] && [ -z "${NOCOLOUR}" ] ; then
+# Set colours based on the --colour option and output redirection status
+if [ -z "${COLOUR}" -a -t 1 -o "${COLOUR}" = "yes" ]; then
BOLD=$(tput bold)
NORMAL=$(tput sgr0)
RED=$(tput setaf 1)${BOLD}
diff --git a/emacs-updater.8 b/emacs-updater.8
index afa9995..c534020 100644
--- a/emacs-updater.8
+++ b/emacs-updater.8
@@ -2,7 +2,7 @@
.\" Copyright 2008-2013 Gentoo Foundation
.\" Distributed under the terms of the GNU General Public License v2 or later
.\"
-.TH emacs-updater 8 "October 2012" "Gentoo Linux"
+.TH emacs-updater 8 "January 2013" "Gentoo Linux"
.SH NAME
emacs-updater \- rebuild Emacs packages
.SH SYNOPSIS
@@ -33,15 +33,25 @@ Rebuild all packages that have byte-compiled Elisp files.
.B -b, --batch
Batch mode, don't ask the user any questions.
.TP
+.BI \-\-color= "mode, " \-\-colour= mode
+Enable or disable colour output.
+.I mode
+can be
+.BR yes ,
+.BR no ,
+or
+.BR auto .
+The default is
+.BR auto ,
+for which colour output is enabled only if standard output is
+connected to a terminal.
+.TP
.B -e, --exact
Match exact versions when remerging packages.
.TP
.B -m, --major
Use only the major version when comparing Emacs version numbers.
.TP
-.B -n, --nocolour, --nocolor
-Disable colour in output.
-.TP
.B -o, --orphans
List orphan files, i.e. files that are not owned by any package.
Implies