Historically, /bin/sh
was the Bourne shell. However, OpenBSD's /bin/sh
is the same program as /bin/ksh
, so in reality any script that works with one will work with the other. If you want to write a more portable script, invoke /bin/sh and don't use any ksh(1) features not found in sh(1) (see the man pages for details.)
if [ ! -d some-directory ]
then
echo does not exist
fi
if ! mkdir -p /somepath
then
echo mkdir failed
fi
This works because every command has an 'exit status'—zero on success, nonzero on error. You can see the exit status of the last command you ran with echo $?
.