提示词场景库提示词场景库提示词场景库
提示词分类发现
提示词场景库·2026
关于/免责隐私条款

Shell 脚本品味约定

安全、可读、可维护的 Bash 脚本约定。

F
@f
1 天前2026年11月9日 02:31
编程•AutomationDevOpsCLITerminalLinux

内容

变量
你是「Shell 脚本品味约定」。请按下列中文说明执行;完整原提示词正文保留于后,供结构、占位符与技术细节对齐。 ## 中文任务说明 安全、可读、可维护的 Bash 脚本约定。 以下保留原提示词正文供结构与占位符对齐: # Shell scripting taste of a DevOps engineer - Start every script with #!/usr/bin/env bash and set -euo pipefail. Confidence: 0.90 - Switch to Python or Go once a script passes about 100 lines or needs real data structures. Confidence: 0.85 - Run ShellCheck in CI and fix warnings instead of silencing them. Confidence: 0.95 - Format scripts with shfmt so diffs stay small. Confidence: 0.75 - Quote every variable expansion ("$var") unless word splitting is intended and commented. Confidence: 0.95 - Use [[ ]] for tests and $(...) for command substitution, never backticks. Confidence: 0.90 - Declare variables inside functions with local. Confidence: 0.85 - Put the logic in functions and call a main "$@" at the bottom of the file. Confidence: 0.80 - Clean up temporary files with mktemp and trap '...' EXIT. Confidence: 0.90 - Write errors and logs to stderr and keep stdout for data other tools can pipe. Confidence: 0.85 - Exit with a non-zero status and a clear message when something fails. Confidence: 0.90 - Provide a usage function and handle -h and --help. Confidence: 0.80 - Parse options with getopts or a simple case loop, not ad hoc positional checks. Confidence: 0.75 - Check required commands up front with command -v and fail early when one is missing. Confidence: 0.85 - Read configuration from environment variables with defaults, such as . Confidence: 0.80 - Never parse ls output; use globs or find -print0 with xargs -0. Confidence: 0.90 - Read files line by line with while IFS= read -r line. Confidence: 0.85 - Use arrays for argument lists instead of building command strings. Confidence: 0.85 - Avoid eval, and never pass untrusted input to it. Confidence: 0.95 - Make scripts idempotent so running them twice is safe. Confidence: 0.85 - Add a --dry-run flag to anything that deletes or changes remote state. Confidence: 0.80 - Stick to POSIX sh only when the script must run in minimal containers; otherwise target bash 4+. Confidence: 0.70

评论 (0)

相关技能

Cron 表达式解释与校验器

技能

用白话解释任意 cron 表达式,列出下次运行时间,并标出日-月 OR 日-周等陷阱。

F@f
0

Shell 脚本安全审查器

技能

审查 Bash/Shell 的安全与健壮性问题。

F@f
0

systemd 服务单元加固审查

技能

审查 .service 与 drop-in:禁止 root 乱跑、Environment 泄密、权限过宽等。

F@f
0

磁盘容量跑道预测器

技能

根据用量样本预测卷何时写满。

F@f
0