Skip to content
Back to skills

Posix Shell Validator

ASecurity

Validate scripts for POSIX compliance with portability checks, bashism detection, and cross-platform compatibility.

  • 1,760 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 2, 2026
ai-agentsshellbashtestingbackend

Works with

  • cli
  • mcp

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned September 2, 2026

npx -y skills add a5c-ai/babysitter --skill posix-shell-validator --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Posix Shell Validator?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Posix Shell Validator
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/a5c-ai-posix-shell-validator-babysitter/badge)](https://www.skillsdirectory.com/skills/a5c-ai-posix-shell-validator-babysitter)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: posix-shell-validator
description: Validate scripts for POSIX compliance with portability checks, bashism detection, and cross-platform compatibility.
allowed-tools: Read, Write, Edit, Bash, Glob, Grep
graph:
  domains: [domain:software-engineering]
  specializations: [specialization:cli-mcp-development]
  skillAreas: [skill-area:cli-design, skill-area:mcp-server-implementation, skill-area:cross-platform-desktop]
  roles: [role:backend-engineer, role:platform-engineer]
  workflows: [workflow:feature-development]
  topics: [topic:developer-experience]

---

# POSIX Shell Validator

Validate scripts for POSIX compliance and portability.

## Capabilities

- Detect bashisms in shell scripts
- Validate POSIX compliance
- Check cross-platform compatibility
- Identify non-portable constructs
- Generate compliance reports
- Suggest portable alternatives

## Usage

Invoke this skill when you need to:
- Validate scripts for POSIX compliance
- Detect bashisms before deployment
- Ensure cross-platform compatibility
- Generate compliance reports

## Common Bashisms to Avoid

```bash
# Bashism → POSIX Alternative

# Arrays
arr=(a b c)           # Use: set -- a b c; or newline-separated
${arr[0]}             # Use: $1 (after set --)

# [[ ]] test
[[ $x == y ]]         # Use: [ "$x" = "y" ]
[[ $x =~ regex ]]     # Use: case or expr

# String substitution
${var/old/new}        # Use: $(echo "$var" | sed 's/old/new/')
${var,,}              # Use: $(echo "$var" | tr '[:upper:]' '[:lower:]')
${var^^}              # Use: $(echo "$var" | tr '[:lower:]' '[:upper:]')

# Arithmetic
((x++))               # Use: x=$((x + 1))
$((x**2))             # Use: $(expr $x \* $x) or awk

# Here strings
cat <<< "$var"        # Use: echo "$var" | cat

# Process substitution
diff <(cmd1) <(cmd2)  # Use: temp files

# Brace expansion
{1..10}               # Use: seq 1 10
file.{txt,md}         # Use: file.txt file.md

# Local variables
local var             # Use: var= (function-scoped in many shells)

# Source
source file           # Use: . file

# Function syntax
function name { }     # Use: name() { }
```

## Validation Script

```bash
#!/bin/sh
# POSIX compliance validator

check_file() {
    file="$1"
    errors=0

    # Check shebang
    head -1 "$file" | grep -q '^#!/bin/bash' && {
        echo "WARNING: $file uses bash shebang"
        errors=$((errors + 1))
    }

    # Check for bashisms
    bashisms='
        \[\[
        \(\(
        \$\{[^}]*//
        \$\{[^}]*,,
        \$\{[^}]*\^\^
        \$\{[^}]*:[-+=?][^}]*\}
        <<<
        <\(
        >\(
        \{[0-9]+\.\.[0-9]+\}
        function[[:space:]]+[a-zA-Z_]
        source[[:space:]]
        declare[[:space:]]
        local[[:space:]]
        readonly[[:space:]]
    '

    for pattern in $bashisms; do
        if grep -En "$pattern" "$file" 2>/dev/null; then
            echo "BASHISM: $file contains: $pattern"
            errors=$((errors + 1))
        fi
    done

    return $errors
}

# Run checkbashisms if available
if command -v checkbashisms >/dev/null 2>&1; then
    checkbashisms -f "$1"
else
    check_file "$1"
fi
```

## Target Processes

- shell-script-development
- cross-platform-cli-compatibility
- cli-unit-integration-testing

Files in this skill

  • README.md817 B
  • SKILL.md3.2 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…