runtime: properly capture the directory from which to run 'shell' and 'run'