From owner-svn-src-all@FreeBSD.ORG Mon Nov 22 23:49:06 2010 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 93B87106564A; Mon, 22 Nov 2010 23:49:06 +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 824E38FC08; Mon, 22 Nov 2010 23:49:06 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oAMNn6cP010256; Mon, 22 Nov 2010 23:49:06 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oAMNn6Ro010254; Mon, 22 Nov 2010 23:49:06 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201011222349.oAMNn6Ro010254@svn.freebsd.org> From: Jilles Tjoelker Date: Mon, 22 Nov 2010 23:49:06 +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: r215727 - head/bin/sh 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: Mon, 22 Nov 2010 23:49:06 -0000 Author: jilles Date: Mon Nov 22 23:49:06 2010 New Revision: 215727 URL: http://svn.freebsd.org/changeset/base/215727 Log: sh: Fix confusing behaviour if chdir succeeded but getcwd failed in cd -P. If getcwd fails, do not treat this as an error, but print a warning and unset PWD. This is similar to the behaviour when starting the shell in a directory whose name cannot be determined. Modified: head/bin/sh/cd.c Modified: head/bin/sh/cd.c ============================================================================== --- head/bin/sh/cd.c Mon Nov 22 23:35:29 2010 (r215726) +++ head/bin/sh/cd.c Mon Nov 22 23:49:06 2010 (r215727) @@ -219,10 +219,13 @@ cdphysical(char *dest) char *p; INTOFF; - if (chdir(dest) < 0 || (p = findcwd(NULL)) == NULL) { + if (chdir(dest) < 0) { INTON; return (-1); } + p = findcwd(NULL); + if (p == NULL) + out2fmt_flush("cd: warning: failed to get name of current directory\n"); updatepwd(p); INTON; return (0); @@ -304,7 +307,7 @@ updatepwd(char *dir) if (prevdir) ckfree(prevdir); prevdir = curdir; - curdir = savestr(dir); + curdir = dir ? savestr(dir) : NULL; setvar("PWD", curdir, VEXPORT); setvar("OLDPWD", prevdir, VEXPORT); }