Initialize readline and set user name before determining working mode.
For an empty mailbox output diagnostics and quit. Read system-wide mail.rc file. Implemented "set ignoreeof".
Showing
1 changed file
with
19 additions
and
5 deletions
... | @@ -151,6 +151,13 @@ mail_cmdline(void *closure, int cont) | ... | @@ -151,6 +151,13 @@ mail_cmdline(void *closure, int cont) |
151 | util_error("Interrupt"); | 151 | util_error("Interrupt"); |
152 | continue; | 152 | continue; |
153 | } | 153 | } |
154 | |||
155 | if (!rc && util_find_env ("ignoreeof")->set) | ||
156 | { | ||
157 | util_error ("Use \"quit\" to quit."); | ||
158 | continue; | ||
159 | } | ||
160 | |||
154 | break; | 161 | break; |
155 | } | 162 | } |
156 | return rc; | 163 | return rc; |
... | @@ -258,9 +265,10 @@ main (int argc, char **argv) | ... | @@ -258,9 +265,10 @@ main (int argc, char **argv) |
258 | /* argument parsing */ | 265 | /* argument parsing */ |
259 | argp_parse (&argp, argc, argv, 0, 0, &args); | 266 | argp_parse (&argp, argc, argv, 0, 0, &args); |
260 | 267 | ||
261 | /* read .mailrc */ | 268 | /* read system-wide mail.rc and user's .mailrc */ |
262 | if ((util_find_env ("rc"))->set) | 269 | if ((util_find_env ("rc"))->set) |
263 | util_do_command ("source %s", getenv ("MAILRC")); | 270 | util_do_command ("source %s", "/etc/mail.rc"); /*FIXME: configurable path*/ |
271 | util_do_command ("source %s", getenv ("MAILRC")); | ||
264 | 272 | ||
265 | /* how should we be running? */ | 273 | /* how should we be running? */ |
266 | if ((mode = util_find_env ("mode")) == NULL || mode->set == 0) | 274 | if ((mode = util_find_env ("mode")) == NULL || mode->set == 0) |
... | @@ -278,6 +286,9 @@ main (int argc, char **argv) | ... | @@ -278,6 +286,9 @@ main (int argc, char **argv) |
278 | argp_program_version); | 286 | argp_program_version); |
279 | } | 287 | } |
280 | 288 | ||
289 | ml_readline_init (); | ||
290 | mail_set_my_name(args.user); | ||
291 | |||
281 | /* Mode is just sending */ | 292 | /* Mode is just sending */ |
282 | if (strlen ("send") == modelen && !strcmp ("send", mode->value)) | 293 | if (strlen ("send") == modelen && !strcmp ("send", mode->value)) |
283 | { | 294 | { |
... | @@ -293,9 +304,6 @@ main (int argc, char **argv) | ... | @@ -293,9 +304,6 @@ main (int argc, char **argv) |
293 | /* Or acting as a normal reader */ | 304 | /* Or acting as a normal reader */ |
294 | else | 305 | else |
295 | { | 306 | { |
296 | ml_readline_init (); | ||
297 | mail_set_my_name(args.user); | ||
298 | |||
299 | /* open the mailbox */ | 307 | /* open the mailbox */ |
300 | if (args.file == NULL) | 308 | if (args.file == NULL) |
301 | { | 309 | { |
... | @@ -319,6 +327,12 @@ main (int argc, char **argv) | ... | @@ -319,6 +327,12 @@ main (int argc, char **argv) |
319 | && !strcmp ("headers", mode->value)) | 327 | && !strcmp ("headers", mode->value)) |
320 | return util_do_command ("from *"); | 328 | return util_do_command ("from *"); |
321 | 329 | ||
330 | if (total == 0) | ||
331 | { | ||
332 | fprintf (ofile, "No mail for %s\n", mail_whoami()); | ||
333 | return 1; | ||
334 | } | ||
335 | |||
322 | /* initial commands */ | 336 | /* initial commands */ |
323 | if ((util_find_env("header"))->set) | 337 | if ((util_find_env("header"))->set) |
324 | util_do_command ("z."); | 338 | util_do_command ("z."); | ... | ... |
-
Please register or sign in to post a comment