chiark / gitweb /
* summer has new -B option for suppressing times of unusual node types.
authorianmdlvl <ianmdlvl>
Sat, 22 Sep 2007 01:05:44 +0000 (01:05 +0000)
committerianmdlvl <ianmdlvl>
Sat, 22 Sep 2007 01:05:44 +0000 (01:05 +0000)
cprogs/summer.1
cprogs/summer.c
debian/changelog

index 1e829bfbd797f90f1f32272e02736abc5f568aea..a77b8c967e07c858c76fd6935e70fbeac6eed3ff 100644 (file)
@@ -80,6 +80,13 @@ Do not print directory sizes. The size column for directories will read \fBdir\f
 Do not print mtime (time of last modification) for symbolic links. The mtime field
 for symbolic links will read \fBlink\fR.
 .TP
+.B \-B
+Do not print any times for special files, symlinks,
+sockets, or fifos.  The atime, mtime and ctime fields
+for these objects will read
+.BR char ", " block ", " link  ", " sock " or " pipe
+instead.
+.TP
 .B \-f
 Include information about errors encountered (for example, unreadable files)
 in the output, and continue processing. The default is to print error information
index 66c790a0fe8e6c7810979835a5fd085a0c844bcb..6a1bc3d9bb5106f0e67126fda719cc252a1bfe31 100644 (file)
@@ -47,7 +47,7 @@
 #define CSUMXL 32
 
 static int quiet=0, hidectime=0, hideatime=0, hidemtime=0;
-static int hidedirsize=0, hidelinkmtime=0, onefilesystem=0;
+static int hidedirsize=0, hidelinkmtime=0, hidextime=0, onefilesystem=0;
 static int filenamefieldsep=' ';
 static FILE *errfile;
 
@@ -163,6 +163,28 @@ static void linktargpath(const char *linktarg) {
   fn_escaped(stdout, linktarg);
 }
 
+static void pu10(void) { printf(" %10s", "?"); }
+
+#define PTIME(stab, memb)  ((stab) ? ptime((stab), (stab)->memb) : pu10())
+
+static void ptime(const struct stat *stab, unsigned long val) {
+  const char *instead;
+
+  if (!hidextime) goto justprint;
+  else if (S_ISCHR(stab->st_mode)) instead= "char";
+  else if (S_ISBLK(stab->st_mode)) instead= "block";
+  else if (S_ISLNK(stab->st_mode)) instead= "link";
+  else if (S_ISSOCK(stab->st_mode)) instead= "sock";
+  else if (S_ISFIFO(stab->st_mode)) instead= "pipe";
+  else {
+  justprint:
+    printf(" %10lu", val);
+    return;
+  }
+
+  printf(" %10s",instead);
+}
+
 struct hardlink {
   dev_t dev;
   ino_t ino;
@@ -170,8 +192,6 @@ struct hardlink {
 };
 static void *hardlinks;
 
-static void pu10(void) { printf(" %10s", "?"); }
-
 static int hardlink_compar(const void *av, const void *bv) {
   const struct hardlink *a=av, *b=bv;
   if (a->ino != b->ino) return b->ino - a->ino;
@@ -250,32 +270,18 @@ static void node(const char *path, unsigned nodeflags, dev_t fs) {
     printf(" %10s %4s %10s %10s", "?","?","?","?");
   }
 
-  if (!hideatime) {
-    if (stab)
-      printf(" %10lu",
-            (unsigned long)stab->st_atime);
-    else
-      pu10();
-  }
+  if (!hideatime)
+    PTIME(stab, st_atime);
 
   if (!hidemtime) {
-    if (stab)
-      if (S_ISLNK(stab->st_mode) && hidelinkmtime)
-       printf(" %10s","link");
-      else
-       printf(" %10lu",
-              (unsigned long)stab->st_mtime);
+    if (stab && S_ISLNK(stab->st_mode) && hidelinkmtime)
+      printf(" %10s","link");
     else
-      pu10();
+      PTIME(stab, st_mtime);
   }
 
-  if (!hidectime) {
-    if (stab)
-      printf(" %10lu",
-            (unsigned long)stab->st_ctime);
-    else
-      pu10();
-  }
+  if (!hidectime)
+    PTIME(stab, st_ctime);
 
   putchar(filenamefieldsep);
   fn_escaped(stdout, path);
@@ -401,6 +407,9 @@ int main(int argc, const char *const *argv) {
       case 'b':
        hidelinkmtime= 1;
        break;
+      case 'B':
+       hidextime= 1;
+       break;
       case 'x':
        onefilesystem= 1;
        break;
index 81859be7a145bdfac361324f049d402cddaa45c2..09456ed2147c5d32ec665ebc5b3410871671e4dc 100644 (file)
@@ -11,10 +11,11 @@ chiark-utils (4.1.22) unstable; urgency=low
       for report and subsequent discussion.
   * chiark-backup Depends on chiark-utils-bin.  Closes: #401611.
   * summer manpage (thanks to Peter Maydell for initial contribution).
+  * summer has new -B option for suppressing times of unusual node types.
   * copyright notices for various scripts.
   * many scripts mentioned in Description and debian/copyright.
 
- -- Ian Jackson <ian@davenant.greenend.org.uk>  Sat, 22 Sep 2007 01:23:04 +0100
+ -- Ian Jackson <ian@davenant.greenend.org.uk>  Sat, 22 Sep 2007 02:05:31 +0100
 
 chiark-utils (4.1.21) unstable; urgency=low