Limited file checking auto completion options to one level of completion.

It could carry on completing from the same options indefinitely.
This commit is contained in:
Marcus Whybrow 2012-05-31 09:20:48 +01:00
parent 234d2cb991
commit fda1dcebfe

View File

@ -66,16 +66,18 @@ _msm() {
else else
case "${COMP_WORDS[3]}" in case "${COMP_WORDS[3]}" in
ram) ram)
world_dir="${server_path}/$DEFAULT_WORLD_STORAGE_PATH" if [[ $COMP_CWORD == 4 ]]; then
local world_dir="${server_path}/$DEFAULT_WORLD_STORAGE_PATH"
# Override with server specific value if present # Override with server specific value if present
server_conf="${server_path}/$DEFAULT_SERVER_CONF" local server_conf="${server_path}/$DEFAULT_SERVER_CONF"
if [ -e "$server_conf" ]; then if [ -f "$server_conf" ]; then
world_dir=$(grep "^WORLD_STORAGE_PATH=\".*\"" $server_conf | awk -F '"' '{print $2}') world_dir=$(grep "^WORLD_STORAGE_PATH=\".*\"" $server_conf | awk -F '"' '{print $2}')
fi fi
if [ -d "$world_dir" ]; then if [ -d "$world_dir" ]; then
options="$(ls -1 "$world_dir")" options="$(ls -1 "$world_dir")"
fi
fi fi
;; ;;
esac esac
@ -96,16 +98,18 @@ _msm() {
else else
case "${COMP_WORDS[3]}" in case "${COMP_WORDS[3]}" in
remove) remove)
whitelist_path="${server_path}/$DEFAULT_WHITELIST" if [[ $COMP_CWORD == 4 ]]; then
local whitelist_path="${server_path}/$DEFAULT_WHITELIST"
# Override with server specific value if present # Override with server specific value if present
server_conf="${server_path}/$DEFAULT_SERVER_CONF" local server_conf="${server_path}/$DEFAULT_SERVER_CONF"
if [ -e "$server_conf" ]; then if [ -f "$server_conf" ]; then
whitelist_path=$(grep "^WHITELIST=\".*\"" $server_conf | awk -F '"' '{print $2}') whitelist_path=$(grep "^WHITELIST=\".*\"" $server_conf | awk -F '"' '{print $2}')
fi fi
if [ -f "$whitelist_path" ]; then if [ -f "$whitelist_path" ]; then
options=$(cat "$whitelist_path") options="$(cat "$whitelist_path")"
fi
fi fi
;; ;;
esac esac