#!/bin/sh die() { echo "$*" >&2; exit 1 } [ -d "$1" ] || die "$1 is not a directory" cd "$1" || die "Cannot cd to $1" shift exec "$@"