summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2005-08-11 07:28:02 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2005-08-11 07:28:02 +0000
commit447745040b16d1dab3e36b0886546f90324ae60b (patch)
tree47b472f393b535f0d3bd1062b27a0888a749a85f
parentf19c3e1593614fe11dbff9c5bc9367c298bd3321 (diff)
downloadmailutils-447745040b16d1dab3e36b0886546f90324ae60b.tar.gz
mailutils-447745040b16d1dab3e36b0886546f90324ae60b.tar.bz2
(mail_cd): Check chdir return value
-rw-r--r--mail/cd.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/mail/cd.c b/mail/cd.c
index 8a71d07d7..35fe1c100 100644
--- a/mail/cd.c
+++ b/mail/cd.c
@@ -1,5 +1,5 @@
/* GNU Mailutils -- a suite of utilities for electronic mail
- Copyright (C) 1999 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2005 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -26,11 +26,19 @@
int
mail_cd (int argc, char **argv)
{
+ char *dir;
+
if (argc > 2)
return 1;
- else if (argc == 2 && (chdir (argv[1]) != 0))
- return 1;
- else if (argc < 2 && chdir (getenv ("HOME")) != 0)
- return 1;
+ else if (argc == 2)
+ dir = argv[1];
+ else
+ dir = getenv ("HOME");
+
+ if (chdir (dir))
+ {
+ mu_error (_("cannot change to '%s': %s"), dir, mu_strerror (errno));
+ return 1;
+ }
return 0;
}

Return to:

Send suggestions and report system problems to the System administrator.