Envsetup: Fix lunch choice with number in zsh

(zsh)$ source build/envsetup.sh; lunch 23
will result in selecting #22 because array in zsh starts from 1
instead of 0. This CL is to fix this issue.

Bug: b/117202855
Test: below commands should have the same output:
    (zsh)$ source build/envsetup.sh; lunch 23
    (zsh)$ source build/envsetup.sh; lunch aosp_walleye-userdebug

Change-Id: I0570585417878bc7c73eda0e1a416232fe147fb4
This commit is contained in:
Jim Tang 2018-10-03 18:25:50 +08:00
parent 9c68021f67
commit 0e3397b225

View file

@ -585,7 +585,13 @@ function lunch()
local choices=($(TARGET_BUILD_APPS= LUNCH_MENU_CHOICES="${LUNCH_MENU_CHOICES[@]}" get_build_var COMMON_LUNCH_CHOICES)) local choices=($(TARGET_BUILD_APPS= LUNCH_MENU_CHOICES="${LUNCH_MENU_CHOICES[@]}" get_build_var COMMON_LUNCH_CHOICES))
if [ $answer -le ${#choices[@]} ] if [ $answer -le ${#choices[@]} ]
then then
selection=${choices[$(($answer-1))]} # array in zsh starts from 1 instead of 0.
if [ -n "$ZSH_VERSION" ]
then
selection=${choices[$(($answer))]}
else
selection=${choices[$(($answer-1))]}
fi
fi fi
else else
selection=$answer selection=$answer