fix: load_servers() clobbering caller's local variables (#39)

load_servers() used `label`, `conn`, `auth_type` as while-read loop
variables, which clobbered identically-named locals in
add_server_interactive() due to bash dynamic scoping. This caused the
server label to be empty when adding a 2nd+ server.

Rename loop variables to `_l`, `_c`, `_a` to avoid the collision.

Closes #39
This commit is contained in:
SamNet-dev
2026-02-10 01:30:13 -06:00
parent 5b6a5963ad
commit f7f2ae3047

View File

@@ -8160,12 +8160,12 @@ load_servers() {
SERVER_COUNT=0
local conf="$INSTALL_DIR/servers.conf"
[ -f "$conf" ] || return
while IFS='|' read -r label conn auth_type _rest || [ -n "$label" ]; do
[[ "$label" =~ ^#.*$ ]] && continue
[ -z "$label" ] || [ -z "$conn" ] && continue
SERVER_LABELS+=("$label")
SERVER_CONNS+=("$conn")
SERVER_AUTHS+=("${auth_type:-key}")
while IFS='|' read -r _l _c _a _rest || [ -n "$_l" ]; do
[[ "$_l" =~ ^#.*$ ]] && continue
[ -z "$_l" ] || [ -z "$_c" ] && continue
SERVER_LABELS+=("$_l")
SERVER_CONNS+=("$_c")
SERVER_AUTHS+=("${_a:-key}")
SERVER_COUNT=$((SERVER_COUNT + 1))
done < "$conf"
}