BSD 3 development
[unix-history] / usr / src / cmd / at.c
index bc5e60f..a94f701 100644 (file)
@@ -53,6 +53,7 @@ FILE  *file;
 FILE   *ifile;
 char   **environ;
 char   *prefix();
 FILE   *ifile;
 char   **environ;
 char   *prefix();
+char    *getenv();
 FILE   *popen();
 
 main(argc, argv)
 FILE   *popen();
 
 main(argc, argv)
@@ -63,6 +64,7 @@ char **argv;
        char pwbuf[100];
        FILE *pwfil;
        int larg;
        char pwbuf[100];
        FILE *pwfil;
        int larg;
+       char *tmp;
 
        /* argv[1] is the user's time: e.g.,  3AM */
        /* argv[2] is a month name or day of week */
 
        /* argv[1] is the user's time: e.g.,  3AM */
        /* argv[2] is a month name or day of week */
@@ -93,6 +95,7 @@ char **argv;
                signal(SIGINT, onintr);
        file = fopen(fname, "a");
        chmod(fname, 0644);
                signal(SIGINT, onintr);
        file = fopen(fname, "a");
        chmod(fname, 0644);
+       chown(fname,getuid(),getgid());
        if (file == NULL) {
                fprintf(stderr, "at: cannot open memo file\n");
                exit(1);
        if (file == NULL) {
                fprintf(stderr, "at: cannot open memo file\n");
                exit(1);
@@ -107,11 +110,23 @@ char **argv;
        if (environ) {
                char **ep = environ;
                while(*ep)
        if (environ) {
                char **ep = environ;
                while(*ep)
-                       fprintf(file, "%s\n", *ep++);
+               {
+                       fprintf(file, "%s\nexport ", *ep);
+                       for(tmp = *ep ; *tmp != '=' ; tmp++) putc(*tmp,file);
+                       putc('\n',file);
+                       ep++;
+               }
        }
        }
+       /* see if the SHELL variable in the current enviroment is /bin/csh
+        * and in that case, use the csh as the shell
+        */
+       if(strcmp(getenv("SHELL"), "/bin/csh") == 0)
+               fprintf(file, "%s\n", "csh << 'xxFUNNYxx'");
        while((c = getc(ifile)) != EOF) {
                putc(c, file);
        }
        while((c = getc(ifile)) != EOF) {
                putc(c, file);
        }
+       if(strcmp(getenv("SHELL"), "/bin/csh") == 0)
+               fprintf(file, "%s\n", "xxFUNNYxx");
        exit(0);
 }
 
        exit(0);
 }