summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorVincent Labrecque <vincent@cvs.openbsd.org>2004-03-05 22:02:19 +0000
committerVincent Labrecque <vincent@cvs.openbsd.org>2004-03-05 22:02:19 +0000
commit425dd833ffc9ace6bd476aced46b4f5b3d98566d (patch)
treee9fc9dcdb2431252768a515fa47c5e181ee37164 /usr.bin
parent98a88a343710aeed44e07ec9d8b1024388348b20 (diff)
don't panic if we can't getcwd() initially, just chdir("/")
spotted by and ok henning
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mg/dir.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/usr.bin/mg/dir.c b/usr.bin/mg/dir.c
index d9b9721a914..27e9b39da5d 100644
--- a/usr.bin/mg/dir.c
+++ b/usr.bin/mg/dir.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dir.c,v 1.9 2002/07/01 14:33:44 vincent Exp $ */
+/* $OpenBSD: dir.c,v 1.10 2004/03/05 22:02:18 vincent Exp $ */
/*
* Name: MG 2a
@@ -19,8 +19,11 @@ static char cwd[NFILEN];
void
dirinit(void)
{
- if ((wdir = getcwd(cwd, sizeof(cwd))) == NULL)
- panic("Can't get current directory!");
+ if ((wdir = getcwd(cwd, sizeof(cwd))) == NULL) {
+ ewprintf("Can't get current directory!");
+ chdir("/");
+ strlcpy(cwd, "/", sizeof(cwd));
+ }
}
/*