973edf
diff -up at-3.1.12/at.c.shell at-3.1.12/at.c
973edf
--- at-3.1.12/at.c.shell	2009-12-02 13:25:12.706989310 +0100
973edf
+++ at-3.1.12/at.c	2009-12-02 13:26:01.991966200 +0100
973edf
@@ -62,11 +62,8 @@
973edf
 #include <stdlib.h>
973edf
 #include <string.h>
973edf
 
973edf
-#ifdef TM_IN_SYS_TIME
973edf
 #include <sys/time.h>
973edf
-#else
973edf
 #include <time.h>
973edf
-#endif
973edf
 
973edf
 #ifdef HAVE_UNISTD_H
973edf
 #include <unistd.h>
973edf
@@ -244,6 +241,12 @@ writefile(time_t runtimer, char queue)
973edf
     int kill_errno;
973edf
     int rc;
973edf
     int mailsize = 128;
973edf
+    struct timeval tv;
973edf
+    struct timezone tz;
973edf
+    long int i;
973edf
+
973edf
+    gettimeofday(&tv, &tz;;
973edf
+    srandom(getpid()+tv.tv_usec);
973edf
 
973edf
 /* Install the signal handler for SIGINT; terminate after removing the
973edf
  * spool file if necessary
973edf
@@ -461,6 +464,9 @@ writefile(time_t runtimer, char queue)
973edf
     fprintf(fp, " || {\n\t echo 'Execution directory "
973edf
 	    "inaccessible' >&2\n\t exit 1\n}\n");
973edf
 
973edf
+    i = random();
973edf
+    fprintf(fp, "${SHELL:-/bin/sh} << \'marcinDELIMITER%08lx\'\n", i);
973edf
+
973edf
     istty = isatty(fileno(stdin));
973edf
     if (istty) {
973edf
 	fprintf(stderr, "at> ");
973edf
@@ -477,6 +483,7 @@ writefile(time_t runtimer, char queue)
973edf
 	fprintf(stderr, "<EOT>\n");
973edf
     }
973edf
     fprintf(fp, "\n");
973edf
+    fprintf(fp, "marcinDELIMITER%08lx\n", i);
973edf
     if (ferror(fp))
973edf
 	panic("Output error");
973edf
 
973edf
@@ -926,7 +933,7 @@ main(int argc, char **argv)
973edf
 	   It also alows a warning diagnostic to be printed.  Because of the
973edf
 	   possible variance, we always output the diagnostic. */
973edf
 
973edf
-	fprintf(stderr, "warning: commands will be executed using /bin/sh\n");
973edf
+	//fprintf(stderr, "warning: commands will be executed using /bin/sh\n");
973edf
 
973edf
 	writefile(timer, queue);
973edf
 	break;