use shell="" instead of shell=none for no shell,
[unix-history] / usr / src / usr.bin / mail / cmd3.c
index 47739a1..c6c3995 100644 (file)
@@ -1,12 +1,18 @@
 /*
  * Copyright (c) 1980 Regents of the University of California.
 /*
  * Copyright (c) 1980 Regents of the University of California.
- * All rights reserved.  The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that this notice is preserved and that due credit is given
+ * to the University of California at Berkeley. The name of the University
+ * may not be used to endorse or promote products derived from this
+ * software without specific prior written permission. This software
+ * is provided ``as is'' without express or implied warranty.
  */
 
  */
 
-#ifndef lint
-static char *sccsid = "@(#)cmd3.c      5.4 (Berkeley) %G%";
-#endif not lint
+#ifdef notdef
+static char sccsid[] = "@(#)cmd3.c     5.10 (Berkeley) %G%";
+#endif /* notdef */
 
 #include "rcv.h"
 #include <sys/stat.h>
 
 #include "rcv.h"
 #include <sys/stat.h>
@@ -238,7 +244,6 @@ _respond(msgvec)
                        strcpy(buf, cp);
        }
        np = elide(extract(buf, GTO));
                        strcpy(buf, cp);
        }
        np = elide(extract(buf, GTO));
-       mapf(np, rcv);
        /*
         * Delete my name from the reply list,
         * and with it, all my alternate names.
        /*
         * Delete my name from the reply list,
         * and with it, all my alternate names.
@@ -272,7 +277,6 @@ _respond(msgvec)
                cp = skin(hfield("cc", mp));
                if (cp != NOSTR) {
                        np = elide(extract(cp, GCC));
                cp = skin(hfield("cc", mp));
                if (cp != NOSTR) {
                        np = elide(extract(cp, GCC));
-                       mapf(np, rcv);
                        np = delname(np, myname, icequal);
                        if (altnames != 0)
                                for (ap = altnames; *ap; ap++)
                        np = delname(np, myname, icequal);
                        if (altnames != 0)
                                for (ap = altnames; *ap; ap++)
@@ -281,6 +285,7 @@ _respond(msgvec)
                }
        }
        head.h_bcc = NOSTR;
                }
        }
        head.h_bcc = NOSTR;
+       head.h_smopts = NOSTR;
        mail1(&head);
        return(0);
 }
        mail1(&head);
        return(0);
 }
@@ -376,8 +381,6 @@ rexit(e)
 {
        if (sourcing)
                return(1);
 {
        if (sourcing)
                return(1);
-       if (Tflag != NOSTR)
-               close(creat(Tflag, 0600));
        exit(e);
        /*NOTREACHED*/
 }
        exit(e);
        /*NOTREACHED*/
 }
@@ -570,110 +573,25 @@ null(e)
  */
 
 file(argv)
  */
 
 file(argv)
-       char **argv;
+       register char **argv;
 {
        register char *cp;
 {
        register char *cp;
-       int edit;
 
        if (argv[0] == NOSTR) {
                newfileinfo();
 
        if (argv[0] == NOSTR) {
                newfileinfo();
-               return(0);
+               return 0;
        }
        }
-
-       /*
-        * Acker's!  Must switch to the new file.
-        * We use a funny interpretation --
-        *      # -- gets the previous file
-        *      % -- gets the invoker's post office box
-        *      %user -- gets someone else's post office box
-        *      & -- gets invoker's mbox file
-        *      string -- reads the given file
-        */
-
-       cp = getfilename(argv[0], &edit);
-       if (cp == NOSTR)
-               return(-1);
-       if (setfile(cp, edit)) {
+       if ((cp = expand(*argv)) == NOSTR)
+               return -1;
+       strcpy(prevfile, mailname);
+       if (setfile(cp, **argv != '%')) {
                perror(cp);
                perror(cp);
-               return(-1);
+               return -1;
        }
        }
-       announce(0);
+       announce();
        return 0;
 }
 
        return 0;
 }
 
-/*
- * Evaluate the string given as a new mailbox name.
- * Ultimately, we want this to support a number of meta characters.
- * Possibly:
- *     % -- for my system mail box
- *     %user -- for user's system mail box
- *     # -- for previous file
- *     & -- get's invoker's mbox file
- *     file name -- for any other file
- */
-
-char   prevfile[PATHSIZE];
-
-char *
-getfilename(name, aedit)
-       char *name;
-       int *aedit;
-{
-       register char *cp;
-       char savename[BUFSIZ];
-       char oldmailname[BUFSIZ];
-
-       /*
-        * Assume we will be in "edit file" mode, until
-        * proven wrong.
-        */
-       *aedit = 1;
-       switch (*name) {
-       case '%':
-               *aedit = 0;
-               strcpy(prevfile, mailname);
-               if (name[1] != 0) {
-                       strcpy(savename, myname);
-                       strcpy(oldmailname, mailname);
-                       strncpy(myname, name+1, PATHSIZE-1);
-                       myname[PATHSIZE-1] = 0;
-                       findmail();
-                       cp = savestr(mailname);
-                       strcpy(myname, savename);
-                       strcpy(mailname, oldmailname);
-                       return(cp);
-               }
-               strcpy(oldmailname, mailname);
-               findmail();
-               cp = savestr(mailname);
-               strcpy(mailname, oldmailname);
-               return(cp);
-
-       case '#':
-               if (name[1] != 0)
-                       goto regular;
-               if (prevfile[0] == 0) {
-                       printf("No previous file\n");
-                       return(NOSTR);
-               }
-               cp = savestr(prevfile);
-               strcpy(prevfile, mailname);
-               return(cp);
-
-       case '&':
-               strcpy(prevfile, mailname);
-               if (name[1] == 0)
-                       return(mbox);
-               /* Fall into . . . */
-
-       default:
-regular:
-               strcpy(prevfile, mailname);
-               cp = expand(name);
-               return(cp);
-       }
-}
-
 /*
  * Expand file names like echo
  */
 /*
  * Expand file names like echo
  */
@@ -686,9 +604,14 @@ echo(argv)
 
        for (ap = argv; *ap != NOSTR; ap++) {
                cp = *ap;
 
        for (ap = argv; *ap != NOSTR; ap++) {
                cp = *ap;
-               if ((cp = expand(cp)) != NOSTR)
-                       printf("%s ", cp);
+               if ((cp = expand(cp)) != NOSTR) {
+                       if (ap != argv)
+                               putchar(' ');
+                       printf("%s", cp);
+               }
        }
        }
+       putchar('\n');
+
        return(0);
 }
 
        return(0);
 }
 
@@ -745,6 +668,7 @@ _Respond(msgvec)
                head.h_seq++;
        head.h_cc = NOSTR;
        head.h_bcc = NOSTR;
                head.h_seq++;
        head.h_cc = NOSTR;
        head.h_bcc = NOSTR;
+       head.h_smopts = NOSTR;
        mail1(&head);
        return(0);
 }
        mail1(&head);
        return(0);
 }