From owner-svn-src-all@FreeBSD.ORG Fri May 27 20:01:47 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 018E3106566B; Fri, 27 May 2011 20:01:47 +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 CC21C8FC13; Fri, 27 May 2011 20:01:46 +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 p4RK1kbF050588; Fri, 27 May 2011 20:01:46 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p4RK1kmN050584; Fri, 27 May 2011 20:01:46 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201105272001.p4RK1kmN050584@svn.freebsd.org> From: Jilles Tjoelker Date: Fri, 27 May 2011 20:01:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r222381 - in head: bin/sh tools/regression/bin/sh/builtins X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 May 2011 20:01:47 -0000 Author: jilles Date: Fri May 27 20:01:46 2011 New Revision: 222381 URL: http://svn.freebsd.org/changeset/base/222381 Log: sh: Correct criterion for using CDPATH in cd. CDPATH should be ignored not only for pathnames starting with '/' but also for pathnames whose first component is '.' or '..'. The man page already describes this behaviour. Added: head/tools/regression/bin/sh/builtins/cd6.0 (contents, props changed) head/tools/regression/bin/sh/builtins/cd7.0 (contents, props changed) Modified: head/bin/sh/cd.c Modified: head/bin/sh/cd.c ============================================================================== --- head/bin/sh/cd.c Fri May 27 19:57:58 2011 (r222380) +++ head/bin/sh/cd.c Fri May 27 20:01:46 2011 (r222381) @@ -123,7 +123,10 @@ cdcmd(int argc, char **argv) else dest = "."; } - if (*dest == '/' || (path = bltinlookup("CDPATH", 1)) == NULL) + if (dest[0] == '/' || + (dest[0] == '.' && (dest[1] == '/' || dest[1] == '\0')) || + (dest[0] == '.' && dest[1] == '.' && (dest[2] == '/' || dest[2] == '\0')) || + (path = bltinlookup("CDPATH", 1)) == NULL) path = nullstr; while ((p = padvance(&path, dest)) != NULL) { if (stat(p, &statb) >= 0 && S_ISDIR(statb.st_mode)) { Added: head/tools/regression/bin/sh/builtins/cd6.0 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/bin/sh/builtins/cd6.0 Fri May 27 20:01:46 2011 (r222381) @@ -0,0 +1,10 @@ +# $FreeBSD$ + +set -e +cd -P /bin +d=$PWD +CDPATH=/: +cd -P . +[ "$d" = "$PWD" ] +cd -P ./ +[ "$d" = "$PWD" ] Added: head/tools/regression/bin/sh/builtins/cd7.0 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/bin/sh/builtins/cd7.0 Fri May 27 20:01:46 2011 (r222381) @@ -0,0 +1,15 @@ +# $FreeBSD$ + +set -e +cd /usr/bin +[ "$PWD" = /usr/bin ] +CDPATH=/: +cd . +[ "$PWD" = /usr/bin ] +cd ./ +[ "$PWD" = /usr/bin ] +cd .. +[ "$PWD" = /usr ] +cd /usr/bin +cd ../ +[ "$PWD" = /usr ]