From owner-svn-src-stable@FreeBSD.ORG Fri Jan 27 20:53:37 2012 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DE0C1106566B; Fri, 27 Jan 2012 20:53:37 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AC5B28FC08; Fri, 27 Jan 2012 20:53:37 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q0RKrbMo057848; Fri, 27 Jan 2012 20:53:37 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q0RKrbDL057845; Fri, 27 Jan 2012 20:53:37 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201201272053.q0RKrbDL057845@svn.freebsd.org> From: Jilles Tjoelker Date: Fri, 27 Jan 2012 20:53:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r230624 - in stable/9: bin/sh tools/regression/bin/sh/builtins X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 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: Fri, 27 Jan 2012 20:53:38 -0000 Author: jilles Date: Fri Jan 27 20:53:37 2012 New Revision: 230624 URL: http://svn.freebsd.org/changeset/base/230624 Log: MFC r230095: sh: Properly show "Not a directory" error in cd builtin. The errno message display added in r222292 did not take attempting to cd to a non-directory or something that cannot be stat()ed into account. PR: bin/164070 Added: stable/9/tools/regression/bin/sh/builtins/cd8.0 - copied unchanged from r230095, head/tools/regression/bin/sh/builtins/cd8.0 Modified: stable/9/bin/sh/cd.c Directory Properties: stable/9/bin/sh/ (props changed) stable/9/tools/regression/bin/sh/ (props changed) Modified: stable/9/bin/sh/cd.c ============================================================================== --- stable/9/bin/sh/cd.c Fri Jan 27 20:18:31 2012 (r230623) +++ stable/9/bin/sh/cd.c Fri Jan 27 20:53:37 2012 (r230624) @@ -130,7 +130,12 @@ cdcmd(int argc, char **argv) (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 Copied: stable/9/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/9/tools/regression/bin/sh/builtins/cd8.0 Fri Jan 27 20:53:37 2012 (r230624, 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