diff options
author | 2009-07-31 22:06:46 +0200 | |
---|---|---|
committer | 2009-07-31 22:06:46 +0200 | |
commit | bb4bea74c8628c68760719cbbd4c298a16c4cba0 (patch) | |
tree | fbb30c2c7d51f85e1045f41124d4e40f30c3f7f0 /eselect-ruby | |
parent | Remove symlinks or link to latest still available ruby on emerge -C ruby, bug... (diff) | |
download | ruby-scripts-bb4bea74c8628c68760719cbbd4c298a16c4cba0.tar.gz ruby-scripts-bb4bea74c8628c68760719cbbd4c298a16c4cba0.tar.bz2 ruby-scripts-bb4bea74c8628c68760719cbbd4c298a16c4cba0.zip |
Fixing check_target() and array length check
Diffstat (limited to 'eselect-ruby')
-rw-r--r-- | eselect-ruby/ruby.eselect | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/eselect-ruby/ruby.eselect b/eselect-ruby/ruby.eselect index 85cb5eb..e40246b 100644 --- a/eselect-ruby/ruby.eselect +++ b/eselect-ruby/ruby.eselect @@ -24,17 +24,17 @@ check_target() { # number from the list if is_number ${target} && [[ ${target} -ge 1 ]] ; then if [[ ${target} -gt ${#targets[@]} ]] ; then - die -q "Can't use that profile. No suitable Ruby interpreter found." + target="invalid" elif [[ -e "${targets[$(( ${target} - 1 ))]}" ]] ; then target=$(basename ${targets[$((${target} - 1 ))]} ) else write_warning_msg ${targets[$((${target} - 1 ))]} - die -q "Can't use that profile. No suitable Ruby interpreter found." + target="invalid" fi # `rubyXX' string else [[ -e "${ROOT}${bindir}/${target}" ]] || \ - die -q "Can't use that profile. No suitable Ruby interpreter found." + target="invalid" fi echo ${target} @@ -130,7 +130,7 @@ do_list() { write_list_start "Available Ruby profiles:" local targets=( $(find_targets ) ) - if [[ -n ${#targets[@]} ]] ; then + if [[ ${#targets[@]} -ne 0 ]] ; then local i for (( i = 0 ; i < ${#targets[@]} ; i = i + 1 )) ; do local line="$(basename ${targets[${i}]} )" @@ -172,6 +172,8 @@ do_set() { local target=$(check_target ${1}) + [[ $target = "invalid" ]] && die -q "Can't use that profile. No suitable Ruby interpreter found." + remove_symlinks || \ die -q "Could not remove symlinks" |