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