=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mg/dir.c,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- src/usr.bin/mg/dir.c 2006/05/02 17:10:25 1.17 +++ src/usr.bin/mg/dir.c 2007/05/28 17:52:17 1.18 @@ -1,4 +1,4 @@ -/* $OpenBSD: dir.c,v 1.17 2006/05/02 17:10:25 kjell Exp $ */ +/* $OpenBSD: dir.c,v 1.18 2007/05/28 17:52:17 kjell Exp $ */ /* This file is in the public domain. */ @@ -38,19 +38,21 @@ (void)strlcpy(bufc, mgcwd, sizeof(bufc)); if ((bufp = eread("Change default directory: ", bufc, NFILEN, - EFDEF | EFNEW | EFCR)) == NULL) + EFDEF | EFNEW | EFCR | EFFILE)) == NULL) return (ABORT); else if (bufp[0] == '\0') return (FALSE); + /* Append trailing slash */ if (chdir(bufc) == -1) { ewprintf("Can't change dir to %s", bufc); return (FALSE); - } else { - if ((bufp = getcwd(mgcwd, sizeof(mgcwd))) == NULL) - panic("Can't get current directory!"); - ewprintf("Current directory is now %s", bufp); - return (TRUE); } + if ((bufp = getcwd(mgcwd, sizeof(mgcwd))) == NULL) + panic("Can't get current directory!"); + if (mgcwd[strlen(mgcwd) - 1] != '/') + (void)strlcat(mgcwd, "/", sizeof(mgcwd)); + ewprintf("Current directory is now %s", bufp); + return (TRUE); } /*