Index: init.c =================================================================== RCS file: /home/roessler/cvs/mutt/init.c,v retrieving revision 3.6 diff -u -r3.6 init.c --- init.c 24 Jul 2002 08:40:07 -0000 3.6 +++ init.c 3 Aug 2002 19:00:57 -0000 @@ -1305,6 +1305,42 @@ return (source_rc (path, err)); } +static int mutt_parse_cd(BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) +{ + + mutt_extract_token (buf, s, 0); + if (MoreArgs(s)) + { + strfcpy(err->data, _("too many arguments"), err->dsize); + return -1; + } + if (!buf->data[0]) + strfcpy(buf->data, "~/", buf->dsize); + + mutt_expand_path(buf->data, buf->dsize); + if (chdir(buf->data) < 0) { + if (errno == ENOTDIR) { + snprintf(err->data, err->dsize, _("%s is not a directory"), buf->data); + return -1; + } + snprintf(err->data, err->dsize, _("Error running \"%s\"!"), "chdir()"); + return -1; + } + + return 0; +} + +static int mutt_parse_pwd(BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) +{ + if (!getcwd(err->data, err->dsize)) { + strfcpy(err->data, _("Out of memory!"), err->dsize); + return -1; + } + + return -1; +} + + /* line command to execute token scratch buffer to be used by parser. caller should free Index: init.h =================================================================== RCS file: /home/roessler/cvs/mutt/init.h,v retrieving revision 3.19 diff -u -r3.19 init.h --- init.h 24 Jul 2002 09:20:21 -0000 3.19 +++ init.h 3 Aug 2002 19:00:57 -0000 @@ -2660,6 +2660,7 @@ { "auto_view", parse_list, UL &AutoViewList }, { "alternative_order", parse_list, UL &AlternativeOrderList}, { "bind", mutt_parse_bind, 0 }, + { "cd", mutt_parse_cd, 0 }, { "charset-hook", mutt_parse_hook, M_CHARSETHOOK }, #ifdef HAVE_COLOR { "color", mutt_parse_color, 0 }, @@ -2690,6 +2691,7 @@ { "crypt-hook", mutt_parse_hook, M_CRYPTHOOK }, #endif /* HAVE_PGP */ { "push", mutt_parse_push, 0 }, + { "pwd", mutt_parse_pwd, 0 }, { "reply-hook", mutt_parse_hook, M_REPLYHOOK }, { "reset", parse_set, M_SET_RESET }, { "save-hook", mutt_parse_hook, M_SAVEHOOK }, Index: protos.h =================================================================== RCS file: /home/roessler/cvs/mutt/protos.h,v retrieving revision 3.7 diff -u -r3.7 protos.h --- protos.h 29 Apr 2002 17:12:00 -0000 3.7 +++ protos.h 3 Aug 2002 19:00:58 -0000 @@ -335,6 +335,9 @@ pid_t mutt_create_filter (const char *, FILE **, FILE **, FILE **); pid_t mutt_create_filter_fd (const char *, FILE **, FILE **, FILE **, int, int, int); +int mutt_parse_cd(BUFFER *, BUFFER *, unsigned long, BUFFER *); +int mutt_parse_pwd(BUFFER *, BUFFER *, unsigned long, BUFFER *); + ADDRESS *alias_reverse_lookup (ADDRESS *); /* base64.c */