Skip to content

网络测试 菜单全模块执行失败(选项 1-5 均报退出码 1 / unbound variable) #2

Description

@Kotobaxiao-David

问题描述

在运行“网络测试”菜单下的所有子模块(1-5)时,脚本均直接报错崩溃退出[cite: 3]。经在不同 VPS 环境(Ubuntu-24.04, Debian 13)及普通用户 / root 权限下测试,整个网络测试板块完全无法正常使用[cite: 3, 8]。

崩溃的具体模块列表:

    1. 回程路由测试 (backhaul_route_test.sh)[cite: 3, 4]
    1. 带宽测速 (bandwidth_test.sh)[cite: 3, 8]
    1. IP 质量检测 (ip_quality_test.sh)[cite: 3, 5]
    1. 网络质量检测 (network_quality_test.sh)[cite: 3, 6]
    1. 流媒体解锁测试 (streaming_unlock_test.sh)[cite: 3, 7]

报错日志

  1. 选项 1 (backhaul_route_test.sh) 提示变量未定义:
    /tmp/vps_repo_runtime.xxxx/scripts/network_test/backhaul_route_test.sh: line 338: $1: unbound variable[cite: 2, 4]
    [错误] 模块执行失败。退出码:1[cite: 4]

  2. 选项 2 (bandwidth_test.sh) 遇到节点不可用直接崩溃退出:
    [信息] 开始快速测试...
    日本东京(IPA) | 延迟: 1.043ms | 下行: 943.75 Mbps | 上行: 1010.70 Mbps[cite: 8]
    [失败] 澳洲悉尼 - 节点不可用或超时[cite: 8]
    [错误] 模块执行失败。[cite: 8]
    退出码:1 | 模块:scripts/network_test/bandwidth_test.sh[cite: 8]

  3. 选项 3、4、5 (ip_quality_test.sh / network_quality_test.sh / streaming_unlock_test.sh) 均报执行失败:
    [错误] 模块执行失败。[cite: 5, 6, 7]
    退出码:1 | 模块:scripts/network_test/xxxx.sh[cite: 5, 6, 7]

原因分析

  1. 框架在调用子模块时未正确传递位置参数(导致 $1 unbound variable 报错)[cite: 1, 2]。
  2. 各子模块未对单点网络超时(如单个 Speedtest 节点失效)进行错误捕获(try-catch 或 || true),单点失败直接导致整个脚本被 set -e 终止,返回非 0 退出码[cite: 8]。

建议修复方案

  1. 在各子模块脚本顶部对位置参数添加默认防护值:
    "${1:-}"

  2. 优化单点网络请求的错误处理,防止单个测速节点超时或连通失败抛出退出码 1 终止整个脚本执行[cite: 8]。

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions