ls -l obscures important information

matt at oddjob.UUCP matt at oddjob.UUCP
Fri Mar 13 06:55:39 AEST 1987


In article <1264 at sphinx.UChicago.UUCP> kdw1 at sphinx.UUCP (Keith Waclena) writes:
) I don't know what version of Unix you're using (4.[23]?), but System V
) (release 2.0 and higher)'s ls would have displayed a capital S in the 
) example above to indicate that the execute permission was not set.

Good idea.  Here's a change to the 4.3 "ls" (and its man page) to
do the same thing.

*** /tmp/,RCSt1016260	Thu Mar 12 14:28:21 1987
--- ls.c	Thu Mar 12 14:24:36 1987
***************
*** 575,587 ****
  
  int	m1[] = { 1, S_IREAD>>0, 'r', '-' };
  int	m2[] = { 1, S_IWRITE>>0, 'w', '-' };
! int	m3[] = { 2, S_ISUID, 's', S_IEXEC>>0, 'x', '-' };
  int	m4[] = { 1, S_IREAD>>3, 'r', '-' };
  int	m5[] = { 1, S_IWRITE>>3, 'w', '-' };
! int	m6[] = { 2, S_ISGID, 's', S_IEXEC>>3, 'x', '-' };
  int	m7[] = { 1, S_IREAD>>6, 'r', '-' };
  int	m8[] = { 1, S_IWRITE>>6, 'w', '-' };
! int	m9[] = { 2, S_ISVTX, 't', S_IEXEC>>6, 'x', '-' };
  
  int	*m[] = { m1, m2, m3, m4, m5, m6, m7, m8, m9};
  
--- 575,587 ----
  
  int	m1[] = { 1, S_IREAD>>0, 'r', '-' };
  int	m2[] = { 1, S_IWRITE>>0, 'w', '-' };
! int	m3[] = { 3, S_ISUID|(S_IEXEC>>0), 's', S_ISUID, 'S', S_IEXEC>>0, 'x', '-' };
  int	m4[] = { 1, S_IREAD>>3, 'r', '-' };
  int	m5[] = { 1, S_IWRITE>>3, 'w', '-' };
! int	m6[] = { 3, S_ISGID|(S_IEXEC>>3), 's', S_ISGID, 'S', S_IEXEC>>3, 'x', '-' };
  int	m7[] = { 1, S_IREAD>>6, 'r', '-' };
  int	m8[] = { 1, S_IWRITE>>6, 'w', '-' };
! int	m9[] = { 3, S_ISVTX|(S_IEXEC>>6), 't', S_ISVTX, 'T', S_IEXEC>>6, 'x', '-' };
  
  int	*m[] = { m1, m2, m3, m4, m5, m6, m7, m8, m9};
  
***************
*** 596,604 ****
  		register int *pairp = *mp++;
  		register int n = *pairp++;
  
! 		while (--n >= 0 && (flags&*pairp++) == 0)
! 			pairp++;
! 		*lp++ = *pairp;
  	}
  	return (lp);
  }
--- 596,604 ----
  		register int *pairp = *mp++;
  		register int n = *pairp++;
  
! 		while (--n >= 0 && (flags&*pairp) != *pairp)
! 			pairp += 2;
! 		*lp++ = pairp[n>=0];
  	}
  	return (lp);
  }
*** man/man1/ls.1	Mon May 12 16:32:00 1986
--- man.local/man1/ls.1	Thu Mar 12 14:37:56 1987
***************
*** 3,8 ****
--- 3,9 ----
  .\" specifies the terms and conditions for redistribution.
  .\"
  .\"	@(#)ls.1	6.4 (Berkeley) 5/12/86
+ .\"	reflect printing of 'S' or 'T' when unset 'x' bit is hidden
  .\"
  .TH LS 1 "May 12, 1986"
  .UC
***************
*** 195,200 ****
--- 196,206 ----
  See
  .IR  chmod (1)
  for the meaning of this mode.
+ Usually the `s' and `t' characters hide an execute permission bit
+ which is set.
+ If the hidden bit is
+ .I not
+ set, then `S' or `T' is printed instead.
  .PP
  When the sizes of the files in a directory
  are listed, a total count of blocks,
________________________________________________________
Matt	     University		matt at oddjob.uchicago.edu
Crawford     of Chicago     {astrovax,ihnp4}!oddjob!matt



More information about the Comp.unix.wizards mailing list