getcwd(2): saner logics around prepend_path() call