[gentoo-commits] proj/eselect:master commit in: bin/, /

2023-07-08 Thread Ulrich Müller
commit: c6ee01faaeabcab22b29e8d3f671ba6fd7d00724
Author: Ulrich Müller  gentoo  org>
AuthorDate: Sat Jul  8 06:19:02 2023 +
Commit: Ulrich Müller  gentoo  org>
CommitDate: Sat Jul  8 06:19:02 2023 +
URL:https://gitweb.gentoo.org/proj/eselect.git/commit/?id=c6ee01fa

Avoid subshell on startup

* bin/eselect.in (PATH): Avoid subshell.

Signed-off-by: Ulrich Müller  gentoo.org>

 ChangeLog  | 4 
 bin/eselect.in | 3 ++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 65a49f0..932edc3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2023-07-08  Ulrich Müller  
+
+   * bin/eselect.in (PATH): Avoid subshell.
+
 2023-06-12  Ulrich Müller  
 
* configure.ac: Update version to 1.4.25.

diff --git a/bin/eselect.in b/bin/eselect.in
index 36581e1..ee26b80 100755
--- a/bin/eselect.in
+++ b/bin/eselect.in
@@ -62,7 +62,8 @@ umask +rx
 # Sanitise PATH: We don't want to execute Portage's internal helpers
 # if we're called from an ebuild.
 IFS=:
-read -r -d '' -a path < <(printf '%s\0' "${PATH}")
+# Append ${IFS} to prevent any trailing empty field from being dropped
+set -f; path=(${PATH}${IFS}); set +f
 for i in "${!path[@]}"; do
[[ ${path[i]} == */portage?(/*)/ebuild-helpers?(/*) ]] && unset 
"path[i]"
 done



[gentoo-commits] proj/eselect:master commit in: bin/, /

2023-06-07 Thread Ulrich Müller
commit: 9869b3f98c95ec154b7ac5b2af8bcf6201d8127a
Author: Ulrich Müller  gentoo  org>
AuthorDate: Wed Jun  7 08:50:02 2023 +
Commit: Ulrich Müller  gentoo  org>
CommitDate: Wed Jun  7 08:50:02 2023 +
URL:https://gitweb.gentoo.org/proj/eselect.git/commit/?id=9869b3f9

Use printf instead of echo

* bin/eselect.in (PATH): Use printf instead of echo

Signed-off-by: Ulrich Müller  gentoo.org>

 ChangeLog  | 2 ++
 bin/eselect.in | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index aba58d1..87efe93 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2023-06-07  Ulrich Müller  
 
+   * bin/eselect.in (PATH): Use printf instead of echo.
+
* configure.ac: Update version to 1.4.24.
* Tagged 1.4.24 release.
 

diff --git a/bin/eselect.in b/bin/eselect.in
index 41d53d7..36581e1 100755
--- a/bin/eselect.in
+++ b/bin/eselect.in
@@ -62,7 +62,7 @@ umask +rx
 # Sanitise PATH: We don't want to execute Portage's internal helpers
 # if we're called from an ebuild.
 IFS=:
-read -r -d '' -a path < <(echo -n "${PATH}")
+read -r -d '' -a path < <(printf '%s\0' "${PATH}")
 for i in "${!path[@]}"; do
[[ ${path[i]} == */portage?(/*)/ebuild-helpers?(/*) ]] && unset 
"path[i]"
 done



[gentoo-commits] proj/eselect:master commit in: bin/, /

2023-06-07 Thread Ulrich Müller
commit: 55bc97298c80da3a0b26fb44ee86ce6a27a4cc6a
Author: Ulrich Müller  gentoo  org>
AuthorDate: Wed Jun  7 07:22:03 2023 +
Commit: Ulrich Müller  gentoo  org>
CommitDate: Wed Jun  7 07:22:03 2023 +
URL:https://gitweb.gentoo.org/proj/eselect.git/commit/?id=55bc9729

Don't append a spurious newline to PATH

* bin/eselect.in (PATH): Don't append a spurious newline.

Fixes: 81dc05871392f5acbf5fadb5bb1991c737e42a5f
Signed-off-by: Ulrich Müller  gentoo.org>

 ChangeLog  | 4 
 bin/eselect.in | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index b0ed346..ef5914e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2023-06-07  Ulrich Müller  
+
+   * bin/eselect.in (PATH): Don't append a spurious newline.
+
 2023-06-06  Ulrich Müller  
 
* configure.ac: Update version to 1.4.23.

diff --git a/bin/eselect.in b/bin/eselect.in
index 483a572..41d53d7 100755
--- a/bin/eselect.in
+++ b/bin/eselect.in
@@ -62,7 +62,7 @@ umask +rx
 # Sanitise PATH: We don't want to execute Portage's internal helpers
 # if we're called from an ebuild.
 IFS=:
-read -r -d '' -a path <<<"${PATH}"
+read -r -d '' -a path < <(echo -n "${PATH}")
 for i in "${!path[@]}"; do
[[ ${path[i]} == */portage?(/*)/ebuild-helpers?(/*) ]] && unset 
"path[i]"
 done



[gentoo-commits] proj/eselect:master commit in: bin/, /

2023-06-05 Thread Ulrich Müller
commit: 58e82125a8adfa89585468f3e6609f46896d313a
Author: Ulrich Müller  gentoo  org>
AuthorDate: Mon Jun  5 17:47:02 2023 +
Commit: Ulrich Müller  gentoo  org>
CommitDate: Mon Jun  5 17:47:02 2023 +
URL:https://gitweb.gentoo.org/proj/eselect.git/commit/?id=58e82125

Quote argument of ":" command

* bin/eselect.in (EPREFIX): Quote argument of ":" command.
This avoids globbing, see: https://www.shellcheck.net/wiki/SC2223
Add some more quotes throughout.

Signed-off-by: Ulrich Müller  gentoo.org>

 ChangeLog  | 6 ++
 bin/eselect.in | 6 +++---
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index afa6885..701fb9c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2023-06-05  Ulrich Müller  
+
+   * bin/eselect.in (EPREFIX): Quote argument of ":" command.
+   This avoids globbing, see: https://www.shellcheck.net/wiki/SC2223
+   Add some more quotes throughout.
+
 2023-06-04  Ulrich Müller  
 
* doc/developer-guide.txt: Add subsection about module testing.

diff --git a/bin/eselect.in b/bin/eselect.in
index 9109627..c59a09d 100755
--- a/bin/eselect.in
+++ b/bin/eselect.in
@@ -45,7 +45,7 @@ ESELECT_KILL_TARGET="$$"
 # prefix for the build host. EPREFIX defaults to the same, but can be
 # overridden at runtime when building for a different prefix.
 BROOT="@EPREFIX@"
-: ${EPREFIX="${BROOT}"}
+: "${EPREFIX="${BROOT}"}"
 EROOT="${ROOT%${EPREFIX:+/}}${EPREFIX}"
 
 # Remove all alias definitions. Unset functions and variables that are
@@ -126,7 +126,7 @@ unset suffix
 if [[ -z ${action} ]]; then
binname=$(basename "$0")
for prefix in config update{,r} manage 'read'; do
-   if [[ ${binname##${prefix}-} != ${binname} ]]; then
+   if [[ ${binname##${prefix}-} != "${binname}" ]]; then
action=$(basename "$0")
action=${action##${prefix}-}
break
@@ -145,7 +145,7 @@ while [[ ${1##--} != "$1" ]]; do
colour=*|color=*|colour|color)
# accept all arguments that are valid for ls or emerge
case ${1#*=} in
-   yes|y|always|force|$1) colour=yes ;;
+   yes|y|always|force|"$1") colour=yes ;;
no|n|never|none) colour=no ;;
auto|tty|if-tty) colour="" ;;
*) die -q "Invalid argument for ${1%%=*} 
option" ;;



[gentoo-commits] proj/eselect:master commit in: /, bin/

2023-06-05 Thread Ulrich Müller
commit: 81dc05871392f5acbf5fadb5bb1991c737e42a5f
Author: Ulrich Müller  gentoo  org>
AuthorDate: Mon Jun  5 17:59:33 2023 +
Commit: Ulrich Müller  gentoo  org>
CommitDate: Mon Jun  5 17:59:33 2023 +
URL:https://gitweb.gentoo.org/proj/eselect.git/commit/?id=81dc0587

Sanitise PATH

* bin/eselect.in (PATH): Sanitise, remove Portage's internal
ebuild-helpers dir from it.

Signed-off-by: Ulrich Müller  gentoo.org>

 ChangeLog  |  3 +++
 bin/eselect.in | 13 -
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 701fb9c..fe99690 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2023-06-05  Ulrich Müller  
 
+   * bin/eselect.in (PATH): Sanitise, remove Portage's internal
+   ebuild-helpers dir from it.
+
* bin/eselect.in (EPREFIX): Quote argument of ":" command.
This avoids globbing, see: https://www.shellcheck.net/wiki/SC2223
Add some more quotes throughout.

diff --git a/bin/eselect.in b/bin/eselect.in
index c59a09d..483a572 100755
--- a/bin/eselect.in
+++ b/bin/eselect.in
@@ -53,13 +53,24 @@ EROOT="${ROOT%${EPREFIX:+/}}${EPREFIX}"
 "unalias" -a
 unset -f rm
 unset CDPATH GLOBIGNORE
-IFS=$' \t\n'
 
 shopt -s extglob
 shopt -s expand_aliases
 
 umask +rx
 
+# Sanitise PATH: We don't want to execute Portage's internal helpers
+# if we're called from an ebuild.
+IFS=:
+read -r -d '' -a path <<<"${PATH}"
+for i in "${!path[@]}"; do
+   [[ ${path[i]} == */portage?(/*)/ebuild-helpers?(/*) ]] && unset 
"path[i]"
+done
+PATH="${path[*]}"
+unset i path
+
+IFS=$' \t\n'
+
 # Save stderr file descriptor
 if (( BASH_VERSINFO[0] == 4 && BASH_VERSINFO[1] >= 1 || BASH_VERSINFO[0] > 4 ))
 then



[gentoo-commits] proj/eselect:master commit in: bin/, /

2023-03-20 Thread Ulrich Müller
commit: b2d7c42e744cee752b2ad364c98e1d5541316732
Author: Ulrich Müller  gentoo  org>
AuthorDate: Thu Mar 16 17:06:52 2023 +
Commit: Ulrich Müller  gentoo  org>
CommitDate: Thu Mar 16 17:06:52 2023 +
URL:https://gitweb.gentoo.org/proj/eselect.git/commit/?id=b2d7c42e

Remove useless exit message

* bin/eselect.in (trap): Don't output a message, because die()
is verbose enough. Thanks to Florian Schmaus for the suggestion.

Signed-off-by: Ulrich Müller  gentoo.org>

 ChangeLog  | 5 +
 bin/eselect.in | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 7bb4ea4..3057a22 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2023-03-16  Ulrich Müller  
+
+   * bin/eselect.in (trap): Don't output a message, because die()
+   is verbose enough. Thanks to Florian Schmaus for the suggestion.
+
 2023-03-14  Florian Schmaus  
 
* modules/kernel.eselect (do_update, describe_update)

diff --git a/bin/eselect.in b/bin/eselect.in
index 888977c..7a74098 100755
--- a/bin/eselect.in
+++ b/bin/eselect.in
@@ -73,7 +73,7 @@ inherit manip output path-manipulation tests
 
 # Sneaky trick to make die in subshells work. If you don't get
 # it, don't ask...
-trap 'echo "exiting" >&2; exit 250' 15
+trap 'exit 250' 15
 
 # es_do_usage
 # Display eselect usage



[gentoo-commits] proj/eselect:master commit in: bin/, /

2023-02-28 Thread Ulrich Müller
commit: ed29a63568537bb2f4e341ad1415060402b4c21f
Author: Ulrich Müller  gentoo  org>
AuthorDate: Tue Feb 28 18:06:25 2023 +
Commit: Ulrich Müller  gentoo  org>
CommitDate: Tue Feb 28 18:06:25 2023 +
URL:https://gitweb.gentoo.org/proj/eselect.git/commit/?id=ed29a635

Support NO_COLOR

* bin/eselect.in: Disable colours if NO_COLOR is nonempty.

Signed-off-by: Ulrich Müller  gentoo.org>

 ChangeLog  | 4 
 bin/eselect.in | 3 +++
 2 files changed, 7 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 64a5b5e..aab936d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2023-02-28  Ulrich Müller  
+
+   * bin/eselect.in: Disable colours if NO_COLOR is nonempty.
+
 2023-02-27  Ulrich Müller  
 
* configure.ac: Update version to 1.4.21.

diff --git a/bin/eselect.in b/bin/eselect.in
index a521a6f..888977c 100755
--- a/bin/eselect.in
+++ b/bin/eselect.in
@@ -136,6 +136,7 @@ if [[ -z ${action} ]]; then
 fi
 
 # parse global options
+colour=""
 while [[ ${1##--} != "$1" ]]; do
case ${1##--} in
brief)
@@ -185,6 +186,8 @@ fi
 
 # enable colour output and get width of terminal iff stdout is a tty
 if [[ -t 1 ]]; then
+   # command line option overrides NO_COLOR variable
+   [[ -z ${colour} && -n ${NO_COLOR} ]] && colour=no
colours ${colour:-yes}
init_columns
 else



[gentoo-commits] proj/eselect:master commit in: bin/, /

2023-02-27 Thread Ulrich Müller
commit: 92ef7eeca4e90e8ce65fd0b00f438878f94d5e7c
Author: Ulrich Müller  gentoo  org>
AuthorDate: Mon Feb 27 17:14:32 2023 +
Commit: Ulrich Müller  gentoo  org>
CommitDate: Mon Feb 27 17:14:32 2023 +
URL:https://gitweb.gentoo.org/proj/eselect.git/commit/?id=92ef7eec

Update version to 1.4.21

Signed-off-by: Ulrich Müller  gentoo.org>

 ChangeLog  | 3 +++
 bin/eselect.in | 2 +-
 configure.ac   | 2 +-
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 141e377..64a5b5e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2023-02-27  Ulrich Müller  
 
+   * configure.ac: Update version to 1.4.21.
+   * Tagged 1.4.21 release.
+
* misc/eselect.bashcomp (_eselect): Add --eprefix and --root
options.
 

diff --git a/bin/eselect.in b/bin/eselect.in
index 8afbd7e..a521a6f 100755
--- a/bin/eselect.in
+++ b/bin/eselect.in
@@ -105,7 +105,7 @@ es_do_help() {
 es_do_version() {
echo "eselect ${ESELECT_VERSION}"
echo
-   echo "Copyright (c) 2005-2020 Gentoo Authors."
+   echo "Copyright (c) 2005-2023 Gentoo Authors."
echo "Distributed under the terms of the GNU GPL version 2 or later."
 }
 

diff --git a/configure.ac b/configure.ac
index 00fd2d8..4a0fc9a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT(eselect, 1.4.20, esel...@gentoo.org, eselect)
+AC_INIT(eselect, 1.4.21, esel...@gentoo.org, eselect)
 AC_PREREQ(2.59)
 AC_CONFIG_SRCDIR(bin/eselect.in)
 AC_CONFIG_AUX_DIR(config)



[gentoo-commits] proj/eselect:master commit in: bin/, /

2023-02-26 Thread Ulrich Müller
commit: 69150409a534e24107080c5650bbd12bcc8e
Author: James Le Cuirot  gentoo  org>
AuthorDate: Sun Feb 26 23:14:02 2023 +
Commit: Ulrich Müller  gentoo  org>
CommitDate: Sun Feb 26 23:38:35 2023 +
URL:https://gitweb.gentoo.org/proj/eselect.git/commit/?id=69150409

Allow EPREFIX to be overridden for manipulating prefixed ROOT

* bin/eselect.in: Allow EPREFIX to be overridden for manipulating
prefixed ROOT.

Signed-off-by: James Le Cuirot  gentoo.org>
Signed-off-by: Ulrich Müller  gentoo.org>

 ChangeLog  | 5 +
 bin/eselect.in | 7 +--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 6fcf0db..41d4bab 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2023-02-26  James Le Cuirot  
+
+   * bin/eselect.in: Allow EPREFIX to be overridden for manipulating
+   prefixed ROOT.
+
 2022-05-01  Ulrich Müller  
 
* misc/eselect-mode.el (eselect-mode): For GNU Emacs, use

diff --git a/bin/eselect.in b/bin/eselect.in
index 4caa87e..6a0fdbc 100755
--- a/bin/eselect.in
+++ b/bin/eselect.in
@@ -41,8 +41,11 @@ ESELECT_VERSION="@VERSION@"
 ESELECT_BINARY_NAME="$0"
 ESELECT_KILL_TARGET="$$"
 
-# Support variables for Gentoo Prefix
-EPREFIX="@EPREFIX@"
+# Support variables for Gentoo Prefix. BROOT is hardcoded as the
+# prefix for the build host. EPREFIX defaults to the same, but can be
+# overridden at runtime when building for a different prefix.
+BROOT="@EPREFIX@"
+: ${EPREFIX="${BROOT}"}
 EROOT="${ROOT%${EPREFIX:+/}}${EPREFIX}"
 
 # Remove all alias definitions. Unset functions and variables that are



[gentoo-commits] proj/eselect:master commit in: bin/, /

2022-01-08 Thread Ulrich Müller
commit: 62501cdddf09cd92689fb5e8f87c4369fd636cf5
Author: Ulrich Müller  gentoo  org>
AuthorDate: Sat Jan  8 20:53:12 2022 +
Commit: Ulrich Müller  gentoo  org>
CommitDate: Sat Jan  8 20:53:12 2022 +
URL:https://gitweb.gentoo.org/proj/eselect.git/commit/?id=62501cdd

Error out if --root has no option argument

* bin/eselect.in: Error out if --root has no option argument.

Signed-off-by: Ulrich Müller  gentoo.org>

 ChangeLog  | 2 ++
 bin/eselect.in | 1 +
 2 files changed, 3 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index d40ac8d..ac7c78b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2022-01-08  Ulrich Müller  
 
+   * bin/eselect.in: Error out if --root has no option argument.
+
* configure.ac: Update version to 1.4.19.
* Tagged 1.4.19 release.
 

diff --git a/bin/eselect.in b/bin/eselect.in
index 3422197..4caa87e 100755
--- a/bin/eselect.in
+++ b/bin/eselect.in
@@ -150,6 +150,7 @@ while [[ ${1##--} != "$1" ]]; do
action=${1##--}
;;
root=*|root)
+   [[ ${1#*=} == "$1" ]] && die -q "Option $1 requires an 
argument"
# set ROOT and recalculate EROOT
ROOT=${1#*=}
EROOT="${ROOT%${EPREFIX:+/}}${EPREFIX}"



[gentoo-commits] proj/eselect:master commit in: bin/, /

2016-01-27 Thread Ulrich Müller
commit: 366064aa7478a3f8bee31d37e8b1076649264455
Author: Ulrich Müller  gentoo  org>
AuthorDate: Wed Jan 27 19:25:39 2016 +
Commit: Ulrich Müller  gentoo  org>
CommitDate: Wed Jan 27 19:25:39 2016 +
URL:https://gitweb.gentoo.org/proj/eselect.git/commit/?id=366064aa

Set umask.

* bin/eselect.in: Set umask +rx, bug 572348.

 ChangeLog  | 4 
 bin/eselect.in | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index ac3b25a..5bb2855 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2016-01-27  Ulrich Müller  
+
+   * bin/eselect.in: Set umask +rx, bug 572348.
+
 2015-08-26  Ulrich Müller  
 
* doc/developer-guide.txt:

diff --git a/bin/eselect.in b/bin/eselect.in
index 934a10a..c446d46 100755
--- a/bin/eselect.in
+++ b/bin/eselect.in
@@ -55,6 +55,8 @@ IFS=$' \t\n'
 shopt -s extglob
 shopt -s expand_aliases
 
+umask +rx
+
 # Save stderr file descriptor
 if (( BASH_VERSINFO[0] == 4 && BASH_VERSINFO[1] >= 1 || BASH_VERSINFO[0] > 4 ))
 then



[gentoo-commits] proj/eselect:master commit in: /, bin/

2014-06-05 Thread Ulrich Müller
commit: dc9fac81f559a79b660bccc89e105afb314dd3e0
Author: Ulrich Müller ulm AT gentoo DOT org
AuthorDate: Thu Jun  5 11:16:32 2014 +
Commit: Ulrich Müller ulm AT gentoo DOT org
CommitDate: Thu Jun  5 11:16:32 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/eselect.git;a=commit;h=dc9fac81

Always parse global options. Respect --.

* bin/eselect.in: Parse global options even if we are invoked
as something-config or similar. Respect -- to indicate end
of options.

---
 ChangeLog  |  6 ++
 bin/eselect.in | 64 --
 2 files changed, 41 insertions(+), 29 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 03fe042..c3f0061 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2014-06-05  Ulrich Müller  u...@gentoo.org
+
+   * bin/eselect.in: Parse global options even if we are invoked
+   as something-config or similar. Respect -- to indicate end
+   of options.
+
 2014-05-24  Ulrich Müller  u...@gentoo.org
 
* configure.ac: Update version to 1.4.2.

diff --git a/bin/eselect.in b/bin/eselect.in
index 70e1c20..e2f29ea 100755
--- a/bin/eselect.in
+++ b/bin/eselect.in
@@ -126,34 +126,40 @@ if [[ -z ${action} ]]; then
unset binname prefix
 fi
 
-if [[ -z ${action} ]]  [[ -n ${1##--} ]]; then
-   while [[ ${1##--} != $1 ]]; do
-   case ${1##--} in
-   brief)
-   set_output_mode brief
-   ;;
-   colour=*|color=*|colour|color)
-   # accept all arguments that are valid for ls or 
emerge
-   case ${1#*=} in
-   yes|y|always|force|$1) colour=yes ;;
-   no|n|never|none) colour=no ;;
-   auto|tty|if-tty) colour= ;;
-   *) die -q Invalid argument for 
${1%%=*} option ;;
-   esac
-   ;;
-   help|version)
-   action=${1##--}
-   ;;
-   *)
-   die -q Unknown option $1
-   ;;
-   esac
-   shift
-   done
-   if [[ -z ${action} ]]; then
-   action=$1
-   shift
-   fi
+# parse global options
+while [[ ${1##--} != $1 ]]; do
+   case ${1##--} in
+   brief)
+   set_output_mode brief
+   ;;
+   colour=*|color=*|colour|color)
+   # accept all arguments that are valid for ls or emerge
+   case ${1#*=} in
+   yes|y|always|force|$1) colour=yes ;;
+   no|n|never|none) colour=no ;;
+   auto|tty|if-tty) colour= ;;
+   *) die -q Invalid argument for ${1%%=*} 
option ;;
+   esac
+   ;;
+   help|version)
+   [[ -z ${action} ]] || die -q Too many parameters
+   action=${1##--}
+   ;;
+   )
+   # -- indicates end of options
+   shift
+   break
+   ;;
+   *)
+   die -q Unknown option $1
+   ;;
+   esac
+   shift
+done
+
+if [[ -z ${action}  $# -gt 0 ]]; then
+   action=$1
+   shift
 fi
 
 # enable colour output and get width of terminal iff stdout is a tty
@@ -167,7 +173,7 @@ unset colour
 
 if [[ -n ${action} ]]; then
if is_function es_do_${action}; then
-   [[ $# -gt 0 ]]  die -q Too many parameters
+   [[ $# -eq 0 ]] || die -q Too many parameters
es_do_${action}
else
do_action ${action} $@