Fix #64, prevent tab completion crash when server name all is used

This commit is contained in:
Marcus Whybrow 2012-08-02 10:31:15 +01:00
parent dd30caaa1d
commit 92c9395423

View File

@ -122,13 +122,16 @@ _msm() {
*)
# Server options
local server_path="$SETTINGS_SERVER_STORAGE_PATH/${COMP_WORDS[1]}"
if [[ "${COMP_WORDS[1]}" == "all" ]] || [ -e "$server_path" ]; then
# If the server exists
if [[ "${COMP_WORDS[1]}" == "all" ]]; then
local sid="-1"
else
server_get_id "${COMP_WORDS[1]}"
local sid="$RETURN"
fi
local server_path="$SETTINGS_SERVER_STORAGE_PATH/${COMP_WORDS[1]}"
if [[ "${COMP_WORDS[1]}" == "all" ]] || [ -e "$server_path" ]; then
if [[ $COMP_CWORD == 2 ]]; then
options="start stop restart status connected worlds logroll backup jar whitelist blacklist operator gamemode kick say time toggledownfall give xp save cmd cmdlog console config"
else
@ -142,7 +145,7 @@ _msm() {
if [[ $COMP_CWORD == 3 ]]; then
options="list load ram todisk backup on off"
else
if [[ "${COMP_WORDS[1]}" != "all" ]]; then
case "${COMP_WORDS[3]}" in
ram)
if [[ $COMP_CWORD == 4 ]]; then
@ -170,6 +173,7 @@ _msm() {
;;
esac
fi
fi
;;
jar)
manager_property JAR_STORAGE_PATH
@ -185,6 +189,7 @@ _msm() {
if [[ $COMP_CWORD == 3 ]]; then
options="on off add remove list"
else
if [[ "${COMP_WORDS[1]}" != "all" ]]; then
case "${COMP_WORDS[3]}" in
remove)
if [[ $COMP_CWORD -ge 4 ]]; then
@ -196,6 +201,7 @@ _msm() {
;;
esac
fi
fi
;;
blacklist|bl)
if [[ $COMP_CWORD == 3 ]]; then
@ -206,6 +212,7 @@ _msm() {
if [[ $COMP_CWORD == 4 ]]; then
options="add remove"
else
if [[ "${COMP_WORDS[1]}" != "all" ]]; then
case "${COMP_WORDS[4]}" in
remove)
if [[ $COMP_CWORD -ge 5 ]]; then
@ -217,11 +224,13 @@ _msm() {
;;
esac
fi
fi
;;
ip)
if [[ $COMP_CWORD == 4 ]]; then
options="add remove"
else
if [[ "${COMP_WORDS[1]}" != "all" ]]; then
case "${COMP_WORDS[4]}" in
remove)
if [[ $COMP_CWORD -ge 5 ]]; then
@ -233,6 +242,7 @@ _msm() {
;;
esac
fi
fi
;;
esac
fi
@ -241,6 +251,7 @@ _msm() {
if [[ $COMP_CWORD == 3 ]]; then
options="add remove list"
else
if [[ "${COMP_WORDS[1]}" != "all" ]]; then
case "${COMP_WORDS[3]}" in
remove)
if [[ $COMP_CWORD -ge 4 ]]; then
@ -252,6 +263,7 @@ _msm() {
;;
esac
fi
fi
;;
gamemode|gm)
if [[ $COMP_CWORD == 3 ]]; then
@ -270,9 +282,11 @@ _msm() {
;;
config)
if [[ $COMP_CWORD == 3 ]]; then
if [[ "${COMP_WORDS[1]}" != "all" ]]; then
server_property "$sid" SERVER_CONF
options="$(more "${SERVER_CONF[$sid]}" | sed 's/=.*$//' | grep -v '#')";
fi
fi
;;
esac