Fix shorten_cwd handling