diff options
author | Ulrich Müller <ulm@gentoo.org> | 2009-05-16 11:01:42 +0000 |
---|---|---|
committer | Ulrich Müller <ulm@gentoo.org> | 2009-05-16 11:01:42 +0000 |
commit | b13d1d4bf92f21860e08a96351b31bcf67715ecd (patch) | |
tree | 4eefc6fb68eee96b55b5b55658f5c5a96c6ea447 | |
parent | Remove outdated ruby module, current version is at (diff) | |
download | eselect-b13d1d4bf92f21860e08a96351b31bcf67715ecd.tar.gz eselect-b13d1d4bf92f21860e08a96351b31bcf67715ecd.tar.bz2 eselect-b13d1d4bf92f21860e08a96351b31bcf67715ecd.zip |
Some syntax tweaks.
svn path=/trunk/; revision=539
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | modules/kernel.eselect | 53 |
2 files changed, 26 insertions, 30 deletions
@@ -1,5 +1,8 @@ 2009-05-16 Ulrich Mueller <ulm@gentoo.org> + * modules/kernel.eselect: Fix quoting, simplify syntax for array + arguments, declare local variables, and other stylistic tweaks. + * modules/ruby.eselect: Remove outdated ruby module, as discussed with Alex Legler <a3li@gentoo.org>. Current version is maintained at <git://git.overlays.gentoo.org/proj/ruby-scripts.git>. diff --git a/modules/kernel.eselect b/modules/kernel.eselect index 04a38af..877232c 100644 --- a/modules/kernel.eselect +++ b/modules/kernel.eselect @@ -1,16 +1,17 @@ -# Copyright 1999-2005 Gentoo Foundation +# Copyright 1999-2009 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Id$ DESCRIPTION="Manage the /usr/src/linux symlink" MAINTAINER="ciaranm@gentoo.org" SVN_DATE='$Date$' -VERSION=$(svn_date_to_version "${SVN_DATE}" ) +VERSION=$(svn_date_to_version "${SVN_DATE}") # find a list of kernel symlink targets find_targets() { - for f in ${ROOT}/usr/src/linux-[[:digit:]]* ; do - [[ -d ${f} ]] && echo $(basename ${f} ) + local f + for f in "${ROOT}"/usr/src/linux-[[:digit:]]* ; do + [[ -d ${f} ]] && basename "${f}" done } @@ -21,23 +22,19 @@ remove_symlink() { # set the kernel symlink set_symlink() { - target=${1} + local target=${1} if is_number "${target}" ; then - targets=( $(find_targets ) ) - target=${targets[$(( ${target} - 1 ))]} + local targets=( $(find_targets) ) + target=${targets[target - 1]} fi if [[ -z ${target} ]] ; then die -q "Target \"${1}\" doesn't appear to be valid!" - elif [[ -d "${ROOT}/usr/src/${target}" ]] ; then - pushd "${ROOT}/usr/src" 1>/dev/null - ln -s "${target}" "linux" - popd 1>/dev/null - elif [[ -d "${ROOT}/usr/src/linux-${target}" ]] ; then - pushd "${ROOT}/usr/src" 1>/dev/null - ln -s "linux-${target}" "linux" - popd 1>/dev/null + elif [[ -d ${ROOT}/usr/src/${target} ]] ; then + ln -s "${target}" "${ROOT}/usr/src/linux" + elif [[ -d ${ROOT}/usr/src/linux-${target} ]] ; then + ln -s "linux-${target}" "${ROOT}/usr/src/linux" else - die -q "Target \"${1}\" doesn't appear to be valid!" + die -q "Target \"$1\" doesn't appear to be valid!" fi } @@ -48,11 +45,9 @@ describe_show() { } do_show() { - local kernel - write_list_start "Current kernel symlink:" - if [[ -L "${ROOT}/usr/src/linux" ]] ; then - kernel=$(canonicalise ${ROOT}/usr/src/linux ) + if [[ -L ${ROOT}/usr/src/linux ]] ; then + local kernel=$(canonicalise "${ROOT}/usr/src/linux") write_kv_list_entry "${kernel%/}" "" else write_kv_list_entry "(unset)" "" @@ -66,13 +61,14 @@ describe_list() { } do_list() { - targets=( $(find_targets ) ) + local targets=( $(find_targets) ) write_list_start "Available kernel symlink targets:" if [[ -n ${targets[@]} ]] ; then local i - for (( i = 0 ; i < ${#targets[@]} ; i = i + 1 )) ; do - [[ ${targets[${i}]} == $(basename $(canonicalise ${ROOT}/usr/src/linux)) ]] && \ - targets[${i}]="${targets[${i}]} $(highlight '*' )" + for (( i = 0; i < ${#targets[@]}; i++ )) ; do + [[ ${targets[i]} = \ + $(basename "$(canonicalise "${ROOT}/usr/src/linux")") ]] \ + && targets[i]="${targets[${i}]} $(highlight '*')" done write_numbered_list "${targets[@]}" else @@ -98,19 +94,16 @@ do_set() { if [[ -z ${1} ]] ; then # no parameter die -q "You didn't tell me what to set the symlink to" - - elif [[ -L "${ROOT}/usr/src/linux" ]] ; then + elif [[ -L ${ROOT}/usr/src/linux ]] ; then # existing symlink if ! remove_symlink ; then die -q "Couldn't remove existing symlink" elif ! set_symlink "${1}" ; then die -q "Couldn't set a new symlink" fi - - elif [[ -e "${ROOT}/usr/src/linux" ]] ; then + elif [[ -e ${ROOT}/usr/src/linux ]] ; then # we have something strange - die -q "Sorry, ${ROOT}/usr/src/linux confuses me" - + die -q "${ROOT}/usr/src/linux exists but is not a symlink" else set_symlink "${1}" || die -q "Couldn't set a new symlink" fi |