sh: Show errno messages in cd.

This commit is contained in:
Jilles Tjoelker 2011-05-25 21:38:16 +00:00
parent 81ddb192e8
commit 168b9dd182
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=222292

View File

@ -86,6 +86,7 @@ cdcmd(int argc, char **argv)
struct stat statb; struct stat statb;
int ch, phys, print = 0, getcwderr = 0; int ch, phys, print = 0, getcwderr = 0;
int rc; int rc;
int errno1 = ENOENT;
optreset = 1; optind = 1; opterr = 0; /* initialize getopt */ optreset = 1; optind = 1; opterr = 0; /* initialize getopt */
phys = Pflag; phys = Pflag;
@ -138,9 +139,11 @@ cdcmd(int argc, char **argv)
rc = docd(p, print, phys); rc = docd(p, print, phys);
if (rc >= 0) if (rc >= 0)
return getcwderr ? rc : 0; return getcwderr ? rc : 0;
if (errno != ENOENT)
errno1 = errno;
} }
} }
error("can't cd to %s", dest); error("%s: %s", dest, strerror(errno1));
/*NOTREACHED*/ /*NOTREACHED*/
return 0; return 0;
} }