From d82158a7e001222b1a02dc1bb22a776d25040970 Mon Sep 17 00:00:00 2001 From: bde Date: Mon, 26 Dec 1994 13:02:05 +0000 Subject: Obtained from: partly from 1.1.5 Convert "" to "." for "cd" and "cd ''". chdir("") is required to fail on POSIX systems. --- bin/sh/cd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'bin/sh') diff --git a/bin/sh/cd.c b/bin/sh/cd.c index 29bc1fd..ac44069 100644 --- a/bin/sh/cd.c +++ b/bin/sh/cd.c @@ -33,7 +33,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: cd.c,v 1.2 1994/09/24 02:57:24 davidg Exp $ + * $Id: cd.c,v 1.3 1994/11/06 01:29:26 jkh Exp $ */ #ifndef lint @@ -88,6 +88,8 @@ cdcmd(argc, argv) char **argv; { nextopt(nullstr); if ((dest = *argptr) == NULL && (dest = bltinlookup("HOME", 1)) == NULL) error("HOME not set"); + if (*dest == '\0') + dest = "."; if (dest[0] == '-' && dest[1] == '\0') { dest = prevdir ? prevdir : curdir; print = 1; @@ -220,7 +222,7 @@ top: STPUTC('\0', p); p = grabstackstr(p); INTOFF; - if (chdir(p) < 0) { + if (chdir(*p ? p : ".") < 0) { INTON; return -1; } -- cgit v1.1