summaryrefslogtreecommitdiffstats
path: root/init.c
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2020-05-22 16:13:38 -0700
committerKevin McCarthy <kevin@8t8.us>2020-05-22 16:20:37 -0700
commitc44f0ce5de6865495d3fe61072a4245039476157 (patch)
treebcb008c8a12e60a5e53b00bfa890e03ec85f6e51 /init.c
parentb3ab8ca92d8b91b07e264792d2bff584e3296de7 (diff)
Add cd command to change the current working directory.
Original Author: Christoph Berg <myon@debian.org> Use cases are saving attachments to some other place and others. Modified by Kevin McCarthy: - Fix up documentation to use cmdsynopsis/command/arg. - Add muttrc.man entry. - Fix compilation error. - Clean up the parse_cd() function to use buffers and remove new translation strings.
Diffstat (limited to 'init.c')
-rw-r--r--init.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/init.c b/init.c
index 26f8afcf..5b96a8f7 100644
--- a/init.c
+++ b/init.c
@@ -2865,6 +2865,31 @@ int mutt_parse_rc_line (const char *line, BUFFER *err)
return rc;
}
+static int parse_cd (BUFFER *tmp, BUFFER *s, union pointer_long_t udata, BUFFER *err)
+{
+ mutt_extract_token (tmp, s, 0);
+ mutt_buffer_expand_path (tmp);
+ if (!mutt_buffer_len (tmp))
+ {
+ if (Homedir)
+ mutt_buffer_strcpy (tmp, Homedir);
+ else
+ {
+ mutt_buffer_strcpy (err, _("too few arguments"));
+ return -1;
+ }
+ }
+
+ if (chdir (mutt_b2s (tmp)) != 0)
+ {
+ mutt_buffer_printf (err, "cd: %s", strerror (errno));
+ return (-1);
+ }
+
+ return (0);
+}
+
+
/* line command to execute
token scratch buffer to be used by parser.