ls(1) on System V

Fred Christiansen fred at mot.UUCP
Fri Apr 12 04:07:45 AEST 1985


> > ls(1) has two options to produce multi-column output,
> > 	-C for sorted down the columns
> > 	-x for sorted across the rows
> > 
> > if *any* file in a directory has a full-length (14-char) name,
> > then these options fail, and a single-column output results.
> 
> I thought I would try out 14 character names with ls(1) on System V/iAPX286
> and the result on the 286 was 2 column output, while the VAX produced 5
> column output.
>                         The problem is that strlen(3) is called with
> the name as an argument. When the name is 14 characters long, strlen
> falls off the end of the name, and returns a large number. By dumb
> luck the VAX has a null after the name. The VME/10s around here do not
> have the version of ls with the -C and -x flags.
>		Alan Fargusson (drivax!alan)

A look at the code suggests that "fall[ing] off the end of the name" is
indeed what happens, except for the "serendipity" when a null happens to be
following ... or is there more?  I created several files in a row with 14-char
names on a VME/10 running Sys V R2.  "od -cx ." indicates they were consecutive
with no nulls following.  Yet, with either -C or -x options for ls(1), the
output was five column.  Hmm.
-- 
<< Generic disclaimer >>
Fred Christiansen, Motorola Microsystems, Tempe  {ihnp4,allegra}!sftig!mot!fred
{ihnp4,seismo}!ut-sally!oakhill!mot!fred         {ihnp4,amdahl}!drivax!mot!fred



More information about the Comp.unix.wizards mailing list