- if (chdir(maildir) == NOTOK) {
- adios(maildir, "unable to change directory to");
- }
-
- if (!(mp = folder_read(draftfolder))) {
- adios(NULL, "unable to read draft folder %s", draftfolder);
- }
- if (mp->nummsg == 0) {
- adios(NULL, "no messages in draft folder %s", draftfolder);
- }
- /* parse all the message ranges/sequences and set SELECTED */
- for (msgnum = 0; msgnum < msgp; msgnum++) {
- if (!m_convert(mp, msgs[msgnum])) {
- done(1);
+ if (nmsgs) {
+ folder = folder ? folder : draftfolder;
+ maildir = toabsdir(folder);
+ if (chdir(maildir) == NOTOK) {
+ adios(EX_OSERR, maildir, "unable to change directory to");
+ }
+ if (!(mp = folder_read(folder))) {
+ adios(EX_IOERR, NULL, "unable to read folder %s",
+ folder);
+ }
+ if (mp->nummsg == 0) {
+ adios(EX_DATAERR, NULL, "no messages in folder %s",
+ folder);
+ }
+ /* parse all the msgranges/sequences and set SELECTED */
+ for (msgnum = 0; msgnum < nmsgs; msgnum++) {
+ if (!m_convert(mp, msgs[msgnum])) {
+ exit(EX_USAGE);
+ }