스킬 shell-scripting
💻

shell-scripting

안전 ⚡ 스크립트 포함⚙️ 외부 명령어

撰寫穩健的 Shell 腳本

또한 다음에서 사용할 수 있습니다: Joseph OBrien,Joseph OBrien

Shell 腳本常因未加引號的變數、缺少錯誤處理與不安全模式而失敗。此技能提供可直接上線的範本、安全意識的最佳實務,以及現代命令列替代方案,協助你撰寫可維護的 Bash 與 Zsh 腳本。

지원: Claude Codex Code(CC)
🥉 74 브론즈
1

스킬 ZIP 다운로드

2

Claude에서 업로드

설정 → 기능 → 스킬 → 스킬 업로드로 이동

3

토글을 켜고 사용 시작

테스트해 보기

"shell-scripting" 사용 중입니다. Write a Bash script to process log files safely

예상 결과:

  • Start with proper shebang and safe options: #!/usr/bin/env bash, set -euo pipefail
  • Use null-delimited iteration: while IFS= read -r -d '' file
  • Validate files before processing: [[ -f "$file" ]] || continue
  • Add trap for cleanup: trap cleanup EXIT to remove temporary files

"shell-scripting" 사용 중입니다. How do I handle errors and exit codes properly in a shell script?

예상 결과:

  • Use set -euo pipefail at script start to catch errors immediately
  • Check exit codes explicitly: if command; then ... else ... fi
  • Use ERR trap to capture line numbers: trap 'echo "Error on $LINENO"' ERR
  • Create cleanup function with EXIT trap for resource cleanup

"shell-scripting" 사용 중입니다. Show me how to safely process user input in shell scripts

예상 결과:

  • Always quote variables: "$variable" not $variable
  • Validate input before use with pattern matching: [[ "$input" =~ ^[a-zA-Z0-9]+$ ]]
  • Avoid eval with untrusted input - it enables code injection
  • Use read with explicit prompts and validation

보안 감사

안전
v5 • 1/16/2026

This is a pure knowledge/documentation skill containing shell scripting best practices and templates. The static scanner detected shell patterns (command substitution, backticks, external commands) but these are all in documentation examples showing how to write scripts safely. The content explicitly teaches security best practices including avoiding eval with untrusted input, using mktemp for temp files, and not storing secrets in scripts. No executable code, file access, or network operations exist - only educational examples demonstrating proper shell scripting techniques.

5
스캔된 파일
1,104
분석된 줄 수
2
발견 사항
5
총 감사 수

위험 요인

⚡ 스크립트 포함 (1)
⚙️ 외부 명령어 (2)
감사자: claude 감사 이력 보기 →

품질 점수

55
아키텍처
100
유지보수성
87
콘텐츠
23
커뮤니티
100
보안
91
사양 준수

만들 수 있는 것

撰寫可維護的腳本

學習適合上線使用的安全加引號、錯誤處理與組織模式。

自動化部署任務

建立具備適當 trap 處理器與訊號管理的穩健自動化腳本。

高效管理系統

使用高效的檔案處理、程序管理與文字操作技巧。

이 프롬프트를 사용해 보세요

基本腳本結構
Show me the proper header and structure for a Bash script using best practices including set -euo pipefail.
安全的錯誤處理
How do I use set -euo pipefail, traps, and proper exit codes for robust error handling in shell scripts?
檔案處理
Write a Bash function to safely iterate through files with spaces in names using null delimiters instead of parsing ls.
跨 shell 相容性
Create a script template that works in both Bash and Zsh with conditional Zsh-specific features and advanced globbing.

모범 사례

  • 務必為變數加上引號:"$variable" 而非 $variable,以安全處理空白與特殊字元
  • 在腳本開頭使用 set -euo pipefail 以提早捕捉錯誤並防止默默失敗
  • 在使用外部工具前,以 command -v 驗證命令是否存在以提升可攜性

피하기

  • 不要解析 ls 輸出;改用帶有 nullglob 的 glob 或使用 find 搭配 -print0
  • 避免對不受信任的輸入使用 eval;它會造成程式碼注入與安全性漏洞
  • 不要使用未加引號的變數;它們會在空白處進行字詞分割並展開 glob

자주 묻는 질문

這個技能涵蓋哪些 shell?
主要聚焦 Bash 與 Zsh。大多數模式適用於兩者,僅需針對 Zsh 專屬功能做些微調整。
這個技能使用起來安全嗎?
是的。它僅提供指引,且完全不會執行程式碼或以任何方式存取你的系統。
它會執行 shell 指令嗎?
否。這是一個知識型技能,提供範本、模式與最佳實務文件。
我可以用這個學習 shell scripting 嗎?
是的。它涵蓋基礎、具安全意識的最佳實務,並包含可直接上線的範本。
它會安裝 CLI 工具嗎?
不會。它建議使用像 ripgrep、fd 與 jq 等現代工具,但不會在你的系統上安裝任何東西。
這和閱讀 shell 文件有何不同?
它整理常見任務的實用模式、具安全意識的做法,以及可直接使用的範本。

개발자 세부 정보

파일 구조