From owner-svn-src-stable@FreeBSD.ORG Wed Feb 20 23:26:16 2013 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 0780A244; Wed, 20 Feb 2013 23:26:16 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id BB09820F; Wed, 20 Feb 2013 23:26:15 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r1KNQF0t073128; Wed, 20 Feb 2013 23:26:15 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r1KNQFoO073126; Wed, 20 Feb 2013 23:26:15 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201302202326.r1KNQFoO073126@svn.freebsd.org> From: Jilles Tjoelker Date: Wed, 20 Feb 2013 23:26:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r247063 - in stable/8: bin/sh tools/regression/bin/sh/builtins X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Feb 2013 23:26:16 -0000 Author: jilles Date: Wed Feb 20 23:26:14 2013 New Revision: 247063 URL: http://svnweb.freebsd.org/changeset/base/247063 Log: MFC r222292,r230095: Show errno messages in cd. Added: stable/8/tools/regression/bin/sh/builtins/cd8.0 - copied unchanged from r230095, head/tools/regression/bin/sh/builtins/cd8.0 Modified: stable/8/bin/sh/cd.c Directory Properties: stable/8/bin/sh/ (props changed) stable/8/tools/regression/bin/sh/ (props changed) Modified: stable/8/bin/sh/cd.c ============================================================================== --- stable/8/bin/sh/cd.c Wed Feb 20 23:15:40 2013 (r247062) +++ stable/8/bin/sh/cd.c Wed Feb 20 23:26:14 2013 (r247063) @@ -84,6 +84,7 @@ cdcmd(int argc, char **argv) char *p; struct stat statb; int ch, phys, print = 0; + int errno1 = ENOENT; optreset = 1; optind = 1; opterr = 0; /* initialize getopt */ phys = Pflag; @@ -120,7 +121,12 @@ cdcmd(int argc, char **argv) if (*dest == '/' || (path = bltinlookup("CDPATH", 1)) == NULL) path = nullstr; while ((p = padvance(&path, dest)) != NULL) { - if (stat(p, &statb) >= 0 && S_ISDIR(statb.st_mode)) { + if (stat(p, &statb) < 0) { + if (errno != ENOENT) + errno1 = errno; + } else if (!S_ISDIR(statb.st_mode)) + errno1 = ENOTDIR; + else { if (!print) { /* * XXX - rethink @@ -132,9 +138,11 @@ cdcmd(int argc, char **argv) } if (docd(p, print, phys) >= 0) return 0; + if (errno != ENOENT) + errno1 = errno; } } - error("can't cd to %s", dest); + error("%s: %s", dest, strerror(errno1)); /*NOTREACHED*/ return 0; } Copied: stable/8/tools/regression/bin/sh/builtins/cd8.0 (from r230095, head/tools/regression/bin/sh/builtins/cd8.0) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/tools/regression/bin/sh/builtins/cd8.0 Wed Feb 20 23:26:14 2013 (r247063, copy of r230095, head/tools/regression/bin/sh/builtins/cd8.0) @@ -0,0 +1,26 @@ +# $FreeBSD$ + +# The exact wording of the error message is not standardized, but giving +# a description of the errno is useful. + +LC_ALL=C +export LC_ALL +r=0 + +t() { + exec 3>&1 + errmsg=`cd "$1" 2>&1 >&3 3>&-` + exec 3>&- + case $errmsg in + *[Nn]ot\ a\ directory*) + ;; + *) + printf "Wrong error message for %s: %s\n" "$1" "$errmsg" + r=3 + ;; + esac +} + +t /dev/tty +t /dev/tty/x +exit $r