shell-scripting
Skill0 starsChanged 3 months agoMITView on GitHub
Shell脚本最佳实践:错误处理、参数解析、纯bash技巧、模板.
- Deletes or force-pushes
12 other projects use a version of this.
Adopted by
Most recently taken up by
- DAAF-Contribution-Community/daaftheir own version, first seen Nov 3, 2026
- iuliandita/skillstheir own version, first seen Oct 14, 2026
- sammcj/agentic-codingtheir own version, first seen Oct 8, 2026
- Abdox-menara/guard-skillstheir own version, first seen Aug 24, 2026
- AntheaLaffy/missing-semester-skills-dshtheir own version, first seen Aug 16, 2026
- AntheaLaffy/the-missing-semester-skillstheir own version, first seen Aug 16, 2026
Used with
Projects with it also use ci-cd, testing and 1 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
JohnJBorenSkillci-cd
CI/CD pipeline design, GitHub Actions, testing automation, and deployment strategies
Also in 3 projects that use this
NVIDIASkilltesting
Run Python and Rust tests for physicsnemo-curator using uv + pytest with coverage reporting via pytest-cov, and cargo-nextest for Rust tests. Includes benchmark workflows with pytest-benchmark and criterion.
Also in 3 projects that use this
GoogleSkillcode-review
Adversarial systems, concurrency, memory-model, and architecture code review protocol. Use this skill whenever asked to review code, PRs, diffs, or branches in Filament.
Also in 4 projects that use this
Other versions12 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 12
- mylee04/code-notify★ 288same name
- DAAF-Contribution-Community/daaf★ 239same name
- sammcj/agentic-coding★ 169same name
- iuliandita/skills★ 11same name
- CodingKaiser/kaiser-skills★ 6same name
- ffsshhttiikk/opencode-agents-skills★ 2same name
- yuexueyu/anna-agent-skills★ 2same name
- albertdobmeyer/openskill-forge★ 1same name
- AntheaLaffy/the-missing-semester-skills★ 1same name
- Abdox-menara/guard-skills★ 0same name
2 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository219 other files it gives its agents.
- agent-doctrineSkill
- agent-evaluation-frameworkSkill
- agent-visualization-flintSkill
- hermes-agentSkill
- bailian-cliSkill
- edge-browser-automationSkill
- computer-useSkill
- jupyter-live-kernelSkill
- backup-strategiesSkill
- browser-automationSkill
- chinese-ai-free-apiSkill
- cicd-pipeline-templatesSkill
- copybaraSkill
- devops-toolkitSkill
- email-deliverabilitySkill
- monitoring-observabilitySkill
- obsidian-maintenanceSkill
- obsidian-troubleshootingSkill
- openclaw-windowsSkill
- openclaw-workerSkill
- webhook-subscriptionsSkill
- windows-dev-environmentSkill
- windows-masterSkill
- zero-downtime-deploySkill
- codebase-inspectionSkill
- github-workflowSkill
- adaptive-communicationSkill
- agent-cost-dashboardSkill
- agent-evolutionSkill
- agent-governanceSkill
- agent-osSkill
- context-efficient-toolsSkill
- context-loss-awarenessSkill
- creative-synthesisSkill
- hermes-desktop-pluginsSkill
- emotional-intelligenceSkill
- graph-engineering-workflowSkill
- hermes-maintenanceSkill
- hermes-voiceSkill
- hermes-hygieneSkill
- identity-coreSkill
- income-loopSkill
- master-synthesisSkill
- meta-cognitionSkill
- reasoning-engineSkill
- self-preservationSkill
- teaching-abilitySkill
- temporal-awarenessSkill
- hermes-themesSkill
- thinking-visualizationSkill
- user-modelingSkill
- voice-full-restoreSkill
- knowledge-graph-traversalSkill
- mcp-browser-canvasSkill
- free-api-gatewaySkill
- native-mcpSkill
- web-reverse-apiSkill
- ai-edaSkill
- huggingface-hubSkill
- industrial-ai-siemens-mcpSkill
- The first 60 shown.
The file
Files
Shell 脚本最佳实践
借鉴 dylanaraps/pure-bash-bible (42k⭐) + Google Shell Style Guide。
脚本模板
#!/usr/bin/env bash
set -euo pipefail # 严格模式:出错即停、未定义变量报错、管道错误
# 颜色
RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; NC='\033[0m'
# 用法
usage() {
echo "用法: $0 [选项] <参数>"
echo " -h 帮助"
echo " -v 详细输出"
exit 1
}
# 参数解析
VERBOSE=false
while getopts "hv" opt; do
case $opt in
h) usage ;;
v) VERBOSE=true ;;
*) usage ;;
esac
done
shift $((OPTIND-1))
# 主逻辑
main() {
log "开始执行..."
# ...
}
# 日志
log() { echo -e "${GREEN}[INFO]${NC} $(date '+%H:%M:%S') $*"; }
warn() { echo -e "${YELLOW}[WARN]${NC} $*" >&2; }
err() { echo -e "${RED}[ERROR]${NC} $*" >&2; exit 1; }
main "$@"纯 Bash 技巧(省掉外部命令)
# 字符串操作
s="hello world"
echo "${s^}" # Hello world(首字母大写)
echo "${s^^}" # HELLO WORLD(全大写)
echo "${s,}" # hello world(首字母小写)
echo "${s,,}" # hello world(全小写)
echo "${s/world/郑鑫}" # hello 郑鑫(替换)
# 默认值
echo "${VAR:-默认值}" # VAR为空时用默认值
echo "${VAR:=默认值}" # VAR为空时赋值默认值
: "${VAR:?必须设置}" # VAR为空时报错退出
# 数组
arr=(a b c)
echo "${arr[0]}" # a
echo "${arr[@]}" # a b c(所有元素)
echo "${#arr[@]}" # 3(长度)
arr+=(d) # 追加
# 循环
for i in {1..10}; do echo "$i"; done
for f in *.txt; do echo "$f"; done
# 条件
[[ -f "$file" ]] # 文件存在且是普通文件
[[ -d "$dir" ]] # 目录存在
[[ -z "$str" ]] # 字符串为空
[[ -n "$str" ]] # 字符串非空
[[ "$a" == "$b" ]] # 字符串相等
# 数学运算
((count++))
((total += value))
echo $((10 + 5 * 3)) # 25
# 子串
echo "${s:0:5}" # hello(位置0起取5个字符)
echo "${s#*.}" # txt(去掉最短匹配前缀)
echo "${s##*.}" # txt(去掉最长匹配前缀)
echo "${s%.*}" # file(去掉最短匹配后缀)
echo "${s%%.*}" # file(去掉最长匹配后缀)严格模式详解
set -e # 任何命令返回非0就退出
set -u # 使用未定义变量就退出
set -o pipefail # 管道中任何一个命令失败都算失败
# 如果你需要某个命令失败不退出:
command_that_may_fail || true
# 如果需要检查返回值:
if ! command; then
echo "失败了"
fi常见模式
# 确保在项目根目录
cd "$(dirname "$0")/.."
# 临时目录 + 自动清理
tmp=$(mktemp -d)
trap 'rm -rf "$tmp"' EXIT
# 检查依赖
for cmd in git curl jq; do
if ! command -v "$cmd" >/dev/null; then
err "需要 $cmd,请先安装"
fi
done
# 确认操作
read -p "确认? (y/n) " -n 1 -r; echo
[[ $REPLY =~ ^[Yy]$ ]] || exit 0
# 逐行读文件
while IFS= read -r line; do
echo "$line"
done < file.txtDoes it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

