Package: at
Version: 3.1.9
Tags: patch

I first planned to submit a bug for too verbose at command, but then I
found this old one.  I added a new flag '-s' for 'silent' that inhibits
POSIX2-required warning of using /bin/sh and printing of time.

Other alternative would be defining some environment variable like
'SHUT_UP_AT_I_KNOW_YOU_USE_BIN_SH_THANKS' :-) and check for that.

if (getenv("SHUT_UP_AT_I_KNOW_YOU_USE_BIN_SH_THANKS"))
  silent = 1;

instead of that fragment in getopt-switch.

-- 
Markus Peuhkuri | http://iki.fi/puhuri/
--- at.c~       2005-08-02 12:15:24.000000000 +0300
+++ at.c        2005-09-29 21:20:29.362365032 +0300
@@ -131,7 +131,7 @@
 static void sigc(int signo);
 static void alarmc(int signo);
 static char *cwdname(void);
-static void writefile(time_t runtimer, char queue);
+static void writefile(time_t runtimer, char queue, int silent);
 static void list_jobs(void);
 
 /* Signal catching functions */
@@ -220,7 +220,7 @@
 }
 
 static void
-writefile(time_t runtimer, char queue)
+writefile(time_t runtimer, char queue, int silent)
 {
 /* This does most of the work if at or batch are invoked for writing a job.
  */
@@ -494,7 +494,8 @@
     runtime = localtime(&runtimer);
 
     strftime(timestr, TIMESIZE, TIMEFORMAT_POSIX, runtime);
-    fprintf(stderr, "job %ld at %s\n", jobno, timestr);
+    if (!silent)
+      fprintf(stderr, "job %ld at %s\n", jobno, timestr);
 
     /* Signal atd, if present. Usual precautions taken... */
     fd = open(PIDFILE, O_RDONLY);
@@ -727,8 +728,9 @@
     char *pgm;
 
     int program = AT;          /* our default program */
-    char *options = "q:f:MmvldhVc";    /* default options for at */
+    char *options = "q:f:MmvldhVcs";   /* default options for at */
     int disp_version = 0;
+    int silent = 0;
     time_t timer;
     struct passwd *pwe;
     struct group *ge;
@@ -828,6 +830,10 @@
            disp_version = 1;
            break;
 
+       case 's':
+           silent = 1;
+           break;
+
        case 'c':
            program = CAT;
            options = "";
@@ -910,9 +916,10 @@
           It also alows a warning diagnostic to be printed.  Because of the
           possible variance, we always output the diagnostic. */
 
-       fprintf(stderr, "warning: commands will be executed using /bin/sh\n");
+       if (!silent)
+         fprintf(stderr, "warning: commands will be executed using /bin/sh\n");
 
-       writefile(timer, queue);
+       writefile(timer, queue, silent);
        break;
 
     case BATCH:
@@ -930,7 +937,7 @@
            struct tm *tm = localtime(&timer);
            fprintf(stderr, "%s\n", asctime(tm));
        }
-       writefile(timer, queue);
+       writefile(timer, queue, silent);
        break;
 
     default:
--- at.1.in~    2005-08-02 11:53:11.000000000 +0300
+++ at.1.in     2005-09-29 21:23:12.847511512 +0300
@@ -9,7 +9,7 @@
 .IR queue ]
 .RB [ -f
 .IR file ]
-.RB [ -mldbv ]
+.RB [ -mldbvs ]
 .B TIME
 .br
 .B "at -c"
@@ -27,6 +27,7 @@
 .RI [ job... ]
 .br
 .B batch
+.RB [ -s ]
 .SH DESCRIPTION
 .B at
 and
@@ -227,6 +228,10 @@
 .B
 \-c
 cats the jobs listed on the command line to standard output.
+.TP
+.B
+\-s
+does not print diagnostic output.
 .SH FILES
 .I @ATJBD@
 .br

Reply via email to