More BSD support in shell scripts. Though release_sync.sh still relies o...

Please add my changes towards better BSD support.