fix error check in realpath