#!/bin/bash
INSTALL_PATH="/usr/local"
BFGMINER_INSTALL_PATH="${INSTALL_PATH}/bfgminer"
BFGMINER_REPO="https://github.com/luke-jr/bfgminer.git"
list_last_ten_bfgminer_tags() {
cd ${BFGMINER_INSTALL_PATH}
git for-each-ref --format="%(refname)" --sort=-taggerdate --count=10 refs/tags | cut -c 6-
}
clone_bfgminer() {
cd ${INSTALL_PATH}
git clone ${BFGMINER_REPO} ${BFGMINER_INSTALL_PATH}
}
echo "select number to switch tag or n to continue"
select result in master $(list_last_ten_bfgminer_tags)
do
# HOW DO I CHECK THE INDEX??????? <================================= QUESTION
if [[ ${result} == [0-9] && ${result} < 11 && ${result} > 0 ]]
then
echo "switching to tag ${result}"
cd ${BFGMINER_INSTALL_PATH}
git checkout ${result}
else
echo "continue installing master"
fi
break
done
因此,如果用户输入1,case语句检查比赛上的文字,我怎么能匹配1呢?
相关的和非常有用:http://stackoverflow.com/a/226724/1983854 – fedorqui
@fedorqui谢谢,我已经看到了这一点之前,是一个伟大的职位,我想看看我是否能访问按索引 –
bash选择数组我不明白你的问题,如果价值被返回,你怎么知道哪个答案被选中?你通常想要的是价值而不是索引,这是'select'的全部方便。 –