fixed changing retval in case of failed cd cmd
the first isue of this proposal failed to properly distinguish between failed-chdir and from-a-script conditions, causing any script to abort upon first "cd" command, successful or not.
This commit fixes the issue.