replace basename with a portable alternative