From: phs@cassiopee.imag.fr (Philippe Schnoebelen)
Subject: Suggested new option to GNU ls (from fileutils-3.3)
Reply-To: phs@cosmos.imag.fr (Philippe Schnoebelen)
Organization: GNUs Not Usenet
Distribution: gnu
Date: Fri, 9 Oct 1992 10:56:36 GMT

The ls program in fileutils-3.3 automatically list group_ids in long
format, so that

	% ls -l
and
	% ls -lg

are equivalent. Indeed, the -g option is documented as doing nothing, and
only kept for compatibility purposes. 

However, I sometimes explicitly don't want to have these group_ids.

Cyril Autant <cyril@lifia.imag.fr> and myself added this possibility as a
new option, switched on by -G or by --nogroups.  

Here is a complete patch for sources, mans, etc. (Any comments, suggestions for
improvement, ... are welcome)

*** src/ls.c.orig	Fri Jul 17 22:26:32 1992
--- src/ls.c	Mon Oct  5 20:28:36 1992
***************
*** 346,351 ****
--- 346,356 ----
  /* The exit status to use if we don't get any fatal errors. */
  
  int exit_status;
+ 
+ /* Nonzero means do not list group id of files. Set by -G */
+ 
+ int nogroups;
+ 
  
  void
  main (argc, argv)
***************
*** 435,440 ****
--- 440,446 ----
    {"ignore-backups", 0, 0, 'B'},
    {"classify", 0, 0, 'F'},
    {"file-type", 0, 0, 'F'},
+   {"nogroups", 0, 0, 'G'},
    {"ignore", 1, 0, 'I'},
    {"dereference", 0, 0, 'L'},
    {"literal", 0, 0, 'N'},
***************
*** 535,541 ****
    really_all_files = 0;
    ignore_patterns = 0;
    quote_as_string = 0;
! 
    p = getenv ("COLUMNS");
    line_length = p ? atoi (p) : 80;
  
--- 541,548 ----
    really_all_files = 0;
    ignore_patterns = 0;
    quote_as_string = 0;
!   nogroups = 0;
!   
    p = getenv ("COLUMNS");
    line_length = p ? atoi (p) : 80;
  
***************
*** 551,557 ****
    p = getenv ("TABSIZE");
    tabsize = p ? atoi (p) : 8;
  
!   while ((c = getopt_long (argc, argv, "abcdgiklmnpqrstuw:xABCFI:LNQRST:UX1",
  			   long_options, (int *) 0)) != EOF)
      {
        switch (c)
--- 558,564 ----
    p = getenv ("TABSIZE");
    tabsize = p ? atoi (p) : 8;
  
!   while ((c = getopt_long (argc, argv, "abcdgiklmnpqrstuw:xABCFGI:LNQRST:UX1",
  			   long_options, (int *) 0)) != EOF)
      {
        switch (c)
***************
*** 649,655 ****
  	case 'F':
  	  indicator_style = all;
  	  break;
! 	  
  	case 'I':
  	  add_ignore_pattern (optarg);
  	  break;
--- 656,666 ----
  	case 'F':
  	  indicator_style = all;
  	  break;
! 
!   	case 'G':
! 	  nogroups = 1;
! 	  break;
! 
  	case 'I':
  	  add_ignore_pattern (optarg);
  	  break;
***************
*** 1389,1398 ****
    else
      printf ("%-8.8s ", getuser (f->stat.st_uid));
  
!   if (numeric_users)
!     printf ("%-8u ", (unsigned int) f->stat.st_gid);
!   else
!     printf ("%-8.8s ", getgroup (f->stat.st_gid));
  
    if (S_ISCHR (f->stat.st_mode) || S_ISBLK (f->stat.st_mode))
      printf ("%3u, %3u ", major (f->stat.st_rdev),
--- 1400,1411 ----
    else
      printf ("%-8.8s ", getuser (f->stat.st_uid));
  
!   if (nogroups == 0) {
!      if (numeric_users)
!        printf ("%-8u ", (unsigned int) f->stat.st_gid);
!      else
!        printf ("%-8.8s ", getgroup (f->stat.st_gid));
!   }
  
    if (S_ISCHR (f->stat.st_mode) || S_ISBLK (f->stat.st_mode))
      printf ("%3u, %3u ", major (f->stat.st_rdev),
***************
*** 1797,1810 ****
  usage ()
  {
    fprintf (stderr, "\
! Usage: %s [-abcdgiklmnpqrstuxABCFLNQRSUX1] [-w cols] [-T cols] [-I pattern]\n\
         [--all] [--escape] [--directory] [--inode] [--kilobytes] [--literal]\n\
!        [--numeric-uid-gid] [--hide-control-chars] [--reverse] [--size]\n\
!        [--width=cols] [--tabsize=cols] [--almost-all] [--ignore-backups]\n",
  	   program_name);
    fprintf (stderr, "\
!        [--classify] [--file-type] [--ignore=pattern] [--dereference]\n\
!        [--quote-name] [--recursive] [--sort={none,time,size,extension}]\n\
         [--format={long,verbose,commas,across,vertical,single-column}]\n\
         [--time={atime,access,use,ctime,status}] [path...]\n");
    exit (1);
--- 1810,1824 ----
  usage ()
  {
    fprintf (stderr, "\
! Usage: %s [-abcdgiklmnpqrstuxABCFGLNQRSUX1] [-w cols] [-T cols] [-I pattern]\n\
         [--all] [--escape] [--directory] [--inode] [--kilobytes] [--literal]\n\
!        [--numeric-uid-gid] [--nogroups] [--hide-control-chars] [--reverse]\n\
!        [--size] [--width=cols] [--tabsize=cols] [--almost-all]\n",
  	   program_name);
    fprintf (stderr, "\
!        [--ignore-backups] [--classify] [--file-type] [--ignore=pattern]\n\
!        [--dereference] [--quote-name] [--recursive]\n\
!        [--sort={none,time,size,extension}]\n\
         [--format={long,verbose,commas,across,vertical,single-column}]\n\
         [--time={atime,access,use,ctime,status}] [path...]\n");
    exit (1);
*** man/ls.1.orig	Fri Jun  5 06:27:21 1992
--- man/ls.1	Mon Oct  5 20:33:50 1992
***************
*** 3,14 ****
  ls, dir, vdir \- list contents of directories
  .SH SYNOPSIS
  .B ls
! [\-abcdgiklmnpqrstuxABCFLNQRSUX1] [\-w cols] [\-T cols] [\-I pattern]
  [\-\-all] [\-\-escape] [\-\-directory] [\-\-inode] [\-\-kilobytes]
! [\-\-numeric-uid-gid] [\-\-hide-control-chars] [\-\-reverse] [\-\-size]
! [\-\-width=cols] [\-\-tabsize=cols] [\-\-almost-all] [\-\-ignore-backups]
! [\-\-classify] [\-\-file-type] [\-\-ignore=pattern] [\-\-dereference]
! [\-\-literal] [\-\-quote-name] [\-\-recursive]
  [\-\-sort={none,time,size,extension}]
  [\-\-format={long,verbose,commas,across,vertical,single-column}]
  [\-\-time={atime,access,use,ctime,status}] [path...]
--- 3,14 ----
  ls, dir, vdir \- list contents of directories
  .SH SYNOPSIS
  .B ls
! [\-abcdgiklmnpqrstuxABCFGLNQRSUX1] [\-w cols] [\-T cols] [\-I pattern]
  [\-\-all] [\-\-escape] [\-\-directory] [\-\-inode] [\-\-kilobytes]
! [\-\-numeric-uid-gid] [\-\-nogroups] [\-\-hide-control-chars] [\-\-reverse]
! [\-\-size] [\-\-width=cols] [\-\-tabsize=cols] [\-\-almost-all]
! [\-\-ignore-backups] [\-\-classify] [\-\-file-type] [\-\-ignore=pattern]
! [\-\-dereference] [\-\-literal] [\-\-quote-name] [\-\-recursive]
  [\-\-sort={none,time,size,extension}]
  [\-\-format={long,verbose,commas,across,vertical,single-column}]
  [\-\-time={atime,access,use,ctime,status}] [path...]
***************
*** 115,120 ****
--- 115,123 ----
  regular files that are executable, append a `*'.  The file type
  indicators are `/' for directories, `@' for symbolic links, `|' for
  FIFOs, `=' for sockets, and nothing for regular files.
+ .TP
+ .I "\-G, \-\-nogroups"
+ Do not list group ids.
  .TP
  .I "\-L, \-\-dereference"
  List the files linked to by symbolic links instead of listing the



Newsgroups: gnu.utils.bug