Bashisms vs POSIX Shell Features

Updated

October 31, 2026

Bashisms vs POSIX Shell Features

Feature GNU Bash POSIX sh (/bin/sh)
Test syntax [[ $a == $b ]] [ "$a" = "$b" ]
Arrays arr=(a b) None (use $@ or IFS)
String replacement ${var//find/replace} echo "$var" \| sed 's/find/replace/g'
Function keyword function myfunc() { } myfunc() { }
Local variables local x=1 Not standard POSIX (widely supported)
Regex match [[ $v =~ pattern ]] Use expr or grep

Audit scripts for accidental bashisms using checkbashisms script.sh.