المهارات posix-shell-pro
🐚

posix-shell-pro

آمن ⚙️ الأوامر الخارجية

Write portable POSIX shell scripts for any Unix system

Shell scripts often fail on different systems due to bash-specific features. This skill ensures your scripts run everywhere using strict POSIX compliance.

يدعم: Claude Codex Code(CC)
🥉 74 برونزي
1

تنزيل ZIP المهارة

2

رفع في Claude

اذهب إلى Settings → Capabilities → Skills → Upload skill

3

فعّل وابدأ الاستخدام

اختبرها

استخدام "posix-shell-pro". Create a POSIX script that backs up a directory with validation

النتيجة المتوقعة:

  • #!/bin/sh
  • set -eu
  •  
  • Usage: backup.sh <source_dir> <dest_dir>
  •  
  • if [ $# -lt 2 ]; then
  • echo "Error: source and destination required" >&2
  • exit 1
  • fi
  •  
  • src="$1"
  • dest="$2"
  •  
  • [ -d "$src" ] || { echo "Source not a directory" >&2; exit 1; }
  • mkdir -p "$dest" || exit 1
  •  
  • tar -cf - -C "$src" . | (cd "$dest" && tar -xf -)
  • echo "Backup completed successfully"

استخدام "posix-shell-pro". Check if a command exists portably

النتيجة المتوقعة:

Use: command -v cmd >/dev/null 2>&1 && echo "found" || echo "missing"

التدقيق الأمني

آمن
v1 • 2/24/2026

This is a prompt-only skill with no executable code. Static analysis scanned 0 files and detected 0 security issues with a risk score of 0/100. The skill provides instructional content on POSIX shell scripting best practices and actually promotes security patterns including input validation, safe variable quoting, cleanup traps, and warnings against eval on untrusted input. No network calls, command execution, or sensitive operations detected.

0
الملفات التي تم فحصها
0
الأسطر التي تم تحليلها
1
النتائج
1
إجمالي عمليات التدقيق

عوامل الخطر

⚙️ الأوامر الخارجية
لم يتم تسجيل أي مواقع محددة
تم تدقيقه بواسطة: claude

درجة الجودة

38
الهندسة المعمارية
100
قابلية الصيانة
87
المحتوى
50
المجتمع
100
الأمان
91
الامتثال للمواصفات

ماذا يمكنك بناءه

Cross-platform deployment scripts

Create installation and deployment scripts that work identically on Linux, BSD, macOS, and embedded systems without requiring bash installation.

Container and embedded system tooling

Build lightweight scripts for Alpine Linux, BusyBox, and resource-constrained environments where bash is unavailable.

Legacy system administration

Maintain and modernize scripts for older Unix systems like Solaris, AIX, and legacy Linux that may lack bash or use older versions.

جرّب هذه الموجهات

Basic POSIX script template
Create a POSIX-compliant shell script that validates input arguments and performs a simple file operation. Include proper error handling with set -eu, input validation, and cleanup traps.
Convert bash to POSIX
Convert this bash script to strict POSIX sh. Replace all arrays, [[ conditionals, and bash-specific features with POSIX-compliant equivalents. Explain each change made.
Portable argument parsing
Implement POSIX-compliant argument parsing for a script that accepts -h for help, -v for verbose, -o for output file, and positional arguments. Use while and case without getopts for long options.
Cross-platform compatibility helper
Create a POSIX shell function library that handles platform differences between Linux, BSD, macOS, and BusyBox. Include OS detection, command availability checks, and portable implementations of common utilities.

أفضل الممارسات

  • Always quote variable expansions as "$var" to prevent word splitting and globbing
  • Use printf instead of echo for all output since echo behavior varies across shells
  • Implement cleanup with trap commands to remove temporary files on EXIT INT and TERM signals

تجنب

  • Using [[ conditionals or bash arrays which fail on dash ash and other POSIX shells
  • Using echo -e or echo -n which have inconsistent behavior across different systems
  • Using process substitution <() or source command instead of pipes and dot operator

الأسئلة المتكررة

What is the difference between POSIX sh and bash?
POSIX sh is a standardized minimal shell that works on all Unix systems. Bash adds many extensions like arrays [[ conditionals and process substitution that break portability. Scripts using only POSIX features run on dash ash busybox and all POSIX-compliant shells.
How do I test if my script is truly POSIX compliant?
Run your script with dash ./script.sh since dash is strict about POSIX compliance. Also use ShellCheck with the -s sh flag and checkbashisms to detect bash-specific constructs that will fail on other shells.
Can I use local variables in POSIX sh functions?
The local keyword is not POSIX-compliant. Use unique variable names with function prefixes like func_name_var or be careful with global variables. Some shells support local but it will fail on strict POSIX shells.
What replaces bash arrays in POSIX sh?
Use positional parameters with set -- item1 item2 and iterate with for arg. For delimited data use IFS manipulation with colon or newline separators. Pass multiple values as separate arguments to functions.
Is this skill compatible with Claude Codex and Claude Code?
Yes this skill works with Claude Codex and Claude Code. It provides guidance on POSIX shell scripting regardless of which AI assistant you use to generate or review your scripts.
Will POSIX scripts work in Docker containers?
Yes especially in minimal containers like Alpine Linux which uses busybox ash as the default shell. POSIX scripts work in any container without installing bash making them ideal for small container images.

تفاصيل المطور

المؤلف

sickn33

الترخيص

MIT

مرجع

main

بنية الملفات

📄 SKILL.md