深入探索Shell脚本:库、Getopts与数组的应用
1. 网络配置库的构建与使用
1.1 库的基本理念
在解决问题时,若能使用单个库文件,或尽量减少库之间的依赖,那是较为理想的。若无法做到,通过设置标志变量能有效控制依赖关系。
1.2 网络配置库的结构
网络配置库包含四个文件和一个shell脚本:
- network.sh
- definitions
- debian-network
- redhat-network
- solaris-network
其中, definitions 文件定义通用错误条件和成功状态:
# Various error conditions. It is better to
# provide generic definitions so that the
# individual libraries are that much clearer.
_WRONG_PLATFORM=1
_NO_IP=2
_NO_CONFIG=3
# Success is a variant on failure - best to define this too for consistency.
SUCCESS=0
network.sh 是顶层脚本,
超级会员免费看
订阅专栏 解锁全文
11

被折叠的 条评论
为什么被折叠?



