Ticket #2886: cd-not-a-dir.patch

File cd-not-a-dir.patch, 705 bytes (added by raghuram87, 10 years ago)
  • src/bin/bash/builtins/cd.def

     
    398398     resolved path doesn't exist), fail immediately. */
    399399  if (posixly_correct && nolinks == 0 && canon_failed)
    400400    {
    401       errno = ENOENT;
     401      // if sh_physpath or sh_canonpath failed, it can mean either ENOENT or
     402      // ENOTDIR. errno is already set to ENOENT when path was stat()'ed in
     403      // sh_physpath or sh_canonpath, so if the errno is not ENOENT then errno
     404      // is ENOTDIR.
     405      if (errno != ENOENT)
     406        errno = ENOTDIR;
    402407      return (0);
    403408    }
    404409