Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix off-by-one error

  • Loading branch information...
commit 4ba63653ebbc50db7f99f3b26993866c6f8ed8f8 1 parent aa05790
@pbrisbin authored
Showing with 10 additions and 6 deletions.
  1. +10 −6 downgrade
View
16 downgrade
@@ -140,7 +140,7 @@ run_pacman() {
check_local_packages() {
$searchcache || return 1
- local term="$1" pkg
+ local term="$1" pkg n
local locals=( $(local_packages "$term") )
[[ ${#locals[@]} -eq 0 ]] && return 1
@@ -159,11 +159,13 @@ check_local_packages() {
[[ "$num" = 's' ]] && return 1
- if ! is_valid_index "$num" "${locals[@]}"; then
+ n=$((num-1))
+
+ if ! is_valid_index "$n" "${locals[@]}"; then
errorout 'invalid choice.'
fi
- pkg="${locals[$((num-1))]}"
+ pkg="${locals[$n]}"
run_pacman -U "$pkg" || errorout "could not install package $pkg"
}
@@ -174,7 +176,7 @@ check_arm_packages() {
[[ "$arch" =~ ^(32|64)$ ]] || errorout "$arch is invalid, must be 32 or 64"
- local term="$1" url pkg
+ local term="$1" url pkg n
local arms=( $(arm_packages "$term") )
[[ ${#arms[@]} -eq 0 ]] && return 1
@@ -187,11 +189,13 @@ check_arm_packages() {
prompt_with_quit num 'please choose a version'
- if ! is_valid_index "$num" "${arms[@]}"; then
+ n=$((num-1))
+
+ if ! is_valid_index "$n" "${arms[@]}"; then
errorout 'invalid choice.'
fi
- url=${arms[$((num-1))]}
+ url=${arms[$n]}
pkg="$pkgdir/$(basename $url)"
if [[ ! -d "$pkgdir" ]]; then
Please sign in to comment.
Something went wrong with that request. Please try again.