Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Commit

Permalink
修复单/多选时报错的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
yechentide committed Aug 14, 2022
1 parent 3d166a4 commit c23402a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DSTManager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ set -eu

# 这个脚本里将会读取其他的全部shell脚本, 所以以下全局常量/变量在其他shell脚本里可用
declare OS='MacOS'
declare -r SCRIPT_VERSION='v1.5.4'
declare -r SCRIPT_VERSION='v1.5.5'
declare -r ARCHITECTURE=$(getconf LONG_BIT)
declare -r REPO_ROOT_DIR="$HOME/DSTServerManager"
# DST服务端文件夹
Expand Down
6 changes: 5 additions & 1 deletion lib/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ function select_one(array, color, message, allow_cancel)
local selected = tonumber(io.read())

if selected ~= nil and 1 <= selected and selected <= #array then
return array[selected]
local answer = array[selected]
if allow_cancel then table.remove(array, #array) end
return answer
else
color_print("error", "请输入正确的数字!", true)
end
Expand All @@ -127,6 +129,7 @@ function multi_select(array, color, message, allow_cancel)
local num = tonumber(input)
if num ~= nil and 1 <= num and num <= #array then
if array[num] == "返回" then
table.remove(array, #array)
return "返回"
end
result[#result+1] = num
Expand All @@ -138,6 +141,7 @@ function multi_select(array, color, message, allow_cancel)
end
color_print("info", "你选择的: "..array2string(result), false)
count_down(3, true)
if allow_cancel then table.remove(array, #array) end
return result
end

Expand Down

0 comments on commit c23402a

Please sign in to comment.