aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2012-03-21 19:43:39 -0400
committerMike Frysinger <vapier@gentoo.org>2012-03-21 19:43:39 -0400
commitad045829cfb08a8fd140c738bd689c89a859a37f (patch)
treef28ce61e0979ffa8998ec3350e9db59dc7851127 /gcc-config
parentgcc-config: move SET_X logic up earlier (diff)
downloadgcc-config-ad045829cfb08a8fd140c738bd689c89a859a37f.tar.gz
gcc-config-ad045829cfb08a8fd140c738bd689c89a859a37f.tar.bz2
gcc-config-ad045829cfb08a8fd140c738bd689c89a859a37f.zip
gcc-config: make arg parsing less forgiving with multi-actions
Currently, if someone specifies more than one action flag, we just ignore all but the first. This isn't exactly clear, so just error out if we see too many flags. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'gcc-config')
-rwxr-xr-xgcc-config37
1 files changed, 12 insertions, 25 deletions
diff --git a/gcc-config b/gcc-config
index 754df49..e360b8e 100755
--- a/gcc-config
+++ b/gcc-config
@@ -568,8 +568,11 @@ chop_gcc_ver_spec() {
echo ${splitTED/ /-} # ver-spec
}
-NEED_ACTION="yes"
-DOIT="switch_profile"
+set_doit() {
+ [[ -n ${DOIT} ]] && die_eerror "too many actions selected!"
+ DOIT=$1
+}
+DOIT=""
FORCE="no"
CC_COMP=
@@ -591,16 +594,10 @@ for x in "$@" ; do
FORCE="yes"
;;
-c|--get-current-profile)
- if [[ ${NEED_ACTION} == "yes" ]] ; then
- NEED_ACTION="no"
- DOIT="get_current_profile"
- fi
+ set_doit get_current_profile
;;
-l|--list-profiles)
- if [[ ${NEED_ACTION} == "yes" ]] ; then
- NEED_ACTION="no"
- DOIT="list_profiles"
- fi
+ set_doit list_profiles
;;
-S|--split-profile)
if [[ ( $1 != "-S" && $1 != "--split-profile" ) || $# -eq 1 ]] ; then
@@ -613,22 +610,13 @@ for x in "$@" ; do
exit 0
;;
-E|--print-environ)
- if [[ ${NEED_ACTION} == "yes" ]] ; then
- NEED_ACTION="no"
- DOIT="print_environ"
- fi
+ set_doit print_environ
;;
-B|--get-bin-path)
- if [[ ${NEED_ACTION} == "yes" ]] ; then
- NEED_ACTION="no"
- DOIT="get_bin_path"
- fi
+ set_doit get_bin_path
;;
-L|--get-lib-path)
- if [[ ${NEED_ACTION} == "yes" ]] ; then
- NEED_ACTION="no"
- DOIT="get_lib_path"
- fi
+ set_doit get_lib_path
;;
-x|--debug)
set -x
@@ -687,9 +675,8 @@ for x in "$@" ; do
esac
done
-if [[ ${DOIT} == "switch_profile" ]] && [[ -z ${CC_COMP} ]] ; then
- usage 1
-fi
+[[ -z ${DOIT}${CC_COMP} ]] && usage 1
+: ${DOIT:="switch_profile"}
get_chost
[[ ${DOIT} == "get_current_profile" ]] \