Works with the AI Agents you already use
POSIX Shell Portability Checker (bash to sh)
by Saizul Amin
Make shell scripts run on dash, BusyBox ash, Alpine, macOS and the BSDs.
Free
POSIX Shell Portability Checker (bash to sh)
Example session with this skill installed
Run the POSIX Shell Portability Checker skill on my project and give me a prioritised list of what to fix, with exact changes.
- Read your context and instructions
- Compiled the posix shell portability
Here is what the POSIX Shell Portability Checker (bash to sh) skill produced.
Demo: real, unedited output of the skill's bundled script on a sample input from its test suite.
Output
-Users-SaizulAmin-Saizul-Old-PC-Saizul-com/bc16f08c-2133-4c9b-92e4-fd071b48ec64/scratchpad/src/bash-shell-skills/tests/fixtures/scripts/posix_bad.sh (sh): 23 finding(s)
HIGH PX001 line 4: [[ ]] is not POSIX
> if [[ -n "$1" ]]; then
portable: use [ ] with quoted operands, or case for patterns
MEDIUM PX014 line 5: echo options are not portable (dash prints '-e' literally)
> echo -e "arg: $1"
portable: use printf '%s\n' or printf with escapes
MEDIUM PX003 line 7: the function keyword is not POSIX
> function greet() {
portable: write name() { ...; }
INFO PX016 line 8: local is not POSIX, but dash, ash and BusyBox support it (ksh93 does not)
> local name=$1
portable: keep it if you only target dash/ash; otherwise use uniquely named variables
MEDIUM PX012 line 9: bash parameter expansion (substring, replace, case change, indirection) is not POSIX
> echo "hi ${name^^}"
portable: use ${var#pre} / ${var%suf}, or printf | sed / tr / cut
HIGH PX004 line 11: arrays are not available in sh
> files=(a b c)
portable: use positional parameters (set -- a b c; "$@") or newline-separated strings
HIGH PX008 line 12: source is not POSIX (dash: 'source: not found')
> source ./lib.sh
portable: use . ./file
MEDIUM PX002 line 13: == in [ ] / test is not POSIX
> [ "$x" == "y" ] && echo same
portable: use a single = for string comparison
HIGH PX006 line 14: here-strings (<<<) are not POSIX
> cat <<< "here"
portable: use printf '%s\n' "$var" | cmd, or a heredoc
HIGH PX007 line 15: &> and |& redirections are bash-only (dash runs the command in the background)
> ls &> /dev/null
portable: use >file 2>&1, and 2>&1 | for pipes
MEDIUM PX011 line 16: brace expansion {a,b} / {1..5} is not POSIX (sh prints it literally)
> echo {1..3}
portable: list the words, or loop with while [ "$i" -le 5 ]
MEDIUM PX015 line 17: read -p/-a/-s/-t/-n/-d are bash extensions (POSIX read only has -r)
> read -p "Continue? " ans
portable: printf 'prompt: ' >&2; read -r ans (stty -echo for secrets)
MEDIUM PX013 line 18: bash-only variable: empty in sh
> n=$RANDOM
portable: RANDOM: awk 'BEGIN{srand();print int(rand()*32768)}'; EUID/UID: id -u; HOSTNAME: hostname; script dir: $0
HIGH PX010 line 19: process substitution <( ) is bash-only
> diff <(sort a) <(sort b)
portable: use a temporary file (mktemp) or a pipe
MEDIUM PX009 line 20: let is not POSIX
> let n=n+1
portable: use x=$((x + 1))
MEDIUM PX012 line 21: bash parameter expansion (substring, replace, case change, indirection) is not POSIX
> first=${name:0:1}
portable: use ${var#pre} / ${var%suf}, or printf | sed / tr / cut
MEDIUM PX012 line 22: bash parameter expansion (substring, replace, case change, indirection) is not POSIX
> s=${s//a/b}
portable: use ${var#pre} / ${var%suf}, or printf | sed / tr / cut
MEDIUM PX022 line 23: += append is not POSIX
> x+=more
portable: write x="${x}more"
MEDIUM PX018 line 24: trap ERR/DEBUG/RETURN are bash-only
> trap 'echo fail' ERR
portable: use set -e and trap '...' EXIT
MEDIUM GNU001 line 25: sed -i without a suffix is GNU syntax; BSD/macOS sed treats the next word as the suffix
> sed -i 's/a/b/' file.txt
portable: sed -i.bak 's/a/b/' f && rm f.bak, or sed ... f > f.tmp && mv f.tmp f
MEDIUM GNU003 line 26: date -d is GNU-only (BSD: date -j -f / -v)
> d=$(date -d yesterday +%F)
portable: compute with epoch seconds: date -u +%s, or use python3 / perl for date math
MEDIUM GNU004 line 27: grep -P (PCRE) is GNU-only
> grep -P '\d+' file.txt
portable: use grep -E with POSIX classes ([0-9] instead of \d)
LOW GNU002 line 28: readlink -f is not POSIX (missing on macOS before 12.3 and on some BSDs)
> path=$(readlink -f "$0")
portable: dir=$(cd -- "$(dirname -- "$0")" && pwd -P)
What you do next
- Fix the highest-severity items first.
- Ask your agent to apply the fixes it suggests, then run the skill again to confirm.
- Keep the skill installed and re-run it whenever the project changes.
Connects securely to your tools. The creator never sees your data.
About this skill
Make shell scripts run on dash, BusyBox ash, Alpine, macOS and the BSDs. A deterministic checker finds bashisms in /bin/sh scripts ([[ ]], arrays, function keyword, == in test, $'...', here-strings, &> redirects, source, let/((, process substitution, brace expansion, ${var//x/y}, ${var:0:1}, $RANDOM, echo -e, read -p, pushd, trap ERR) and GNU-only command options (sed -i, date -d, grep -P, readlink -f, stat -c, find -printf, xargs -r, sort -V, base64 -w, getopt, tac/timeout/sha256sum), each with a portable rewrite.
Who it's for
Use when a script fails with "[[ not found", "Bad substitution", "redirection unexpected", "source not found" errors, works in bash but not in Docker/Alpine/Ubuntu sh, works on Linux but not macOS (or the reverse), or when the user asks to make a script POSIX or portable.
What's inside
- Tested, offline Python script(s): check_portability.py (deterministic results, standard library only unless noted)
- Reference guides: gnu-bsd-differences.md, bashism-alternatives.md
- Step-by-step agent instructions in SKILL.md covering: When to use; When not to use; Workflow
Why it's worth it
Generic prompts guess. This skill gives your agent a proven procedure plus scripts that check the facts, so you get the same correct answer every time, with exact fixes instead of vague advice. See the real demo below.
Works with every major AI agent
Built on the open SKILL.md standard: Claude Code, Codex CLI, Cursor, VS Code Copilot, Gemini CLI, Windsurf and 20+ other agents.
Requirements
- Python 3.8+ for the bundled scripts
- No API keys, no account, runs locally
Open source: saizul/bash-shell-skills on GitHub (MIT licence, by Saizul Amin).
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse All Claude Skills.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Free to use
No account required to browse
Trust & safety
Security scan
Security scan passed 2 days ago
- Free with an Agensi account
- Software
Python 3.8+