shlib.sh: be more tolerant of broken /bin/sh implementations