[comp.os.minix] ls -lt *.c doesn't sort files by time as I expected it would

dennis@virtech.uucp (Dennis P. Bednar) (01/11/90)

I have ported the ls.c posted to this newsgroup to Intel's
iRMX286 operating system (the system I use at work). I did this
because the DIR command that is stock with iRMX is pretty shabby,
and doesn't have many nice features. I really wanted to be able
to list files sorted by time order. When I was testing it, I
discovered that if I did:
	ls -lt
it properly sorted all of the files in the current directory, but
if I tried:
	ls -lt *.c
it didn't sort by the time. Any easy fixes to ls.c? Does ls.c
have this same problem on minix (did I break something in my
port)?

(By the way, the port to the iRMX system involved calling unix
library emulation routines for readdir() stat(), file globbing
(expand *.c into many arguments) and time-related routines). At
least one hour was spent tracking down some mysterious compile
errors (cc286) that happened because the "entry" variable passed
to various functions is apparently an undocumented reserved word
to our compiler. I fixed the problem by globbally changing
"entry" to "p_entry". Unfortunately, in iRMX, all arguments
(argv[]) are received in upper case, so I still have to make some
other changes to make it work on this Intel development system
(ha ha Intel, if you can hear me).


On a side topic, are there any better public domain ls.c programs
available? Is the BSD ls.c public domain?


-- 
Dennis Bednar	uunet!virtech!dennis	(703)760-3357(w)   (703)437-4384(h)
Cable & Wireless,	Tysons Corner VA

sung@cs.washington.edu (Sung Kwon Chung) (01/12/90)

In article <1990Jan11.070247.11716@virtech.uucp> dennis@virtech.uucp (Dennis P. Bednar) writes:
>to list files sorted by time order. When I was testing it, I
>discovered that if I did:
>	ls -lt
>it properly sorted all of the files in the current directory, but
>if I tried:
>	ls -lt *.c
>it didn't sort by the time. Any easy fixes to ls.c? Does ls.c
>have this same problem on minix (did I break something in my
>port)?

I found the same problem in minix, too.  It doesn't sort file names
specified in arguemnt.  Here is a quick fix.  (I didn't look carefully
all the codes, so it might cause some bad side effects.  But I havn't
met any, yet.)

-sung
==================
*** ls.c.org	Mon Jan  1 02:25:24 1990
--- ls.c	Wed Jan  3 23:10:25 1990
***************
*** 430,435 ****
--- 430,437 ----
    }
    ostringp = stringp;
  
+   sortfiles(baseindex, lastindex - baseindex); /* sort file names in arg, too*/
+ 
    for (i = baseindex; i < lastindex; ++i) {
  	if (!(flags_f && baseindex == 0) && (include_dirs
  	     || (sortindex[i]->f_stat.st_mode & S_IFMT) != S_IFDIR))

hall@cod.NOSC.MIL (Robert R. Hall) (01/13/90)

In article <1990Jan11.070247.11716@virtech.uucp>, dennis@virtech.uucp (Dennis P. Bednar) writes:
> discovered that if I did:
> 	ls -lt
> it properly sorted all of the files in the current directory, but
> if I tried:
> 	ls -lt *.c
> it didn't sort by the time. Any easy fixes to ls.c? Does ls.c
> have this same problem on minix (did I break something in my
> port)?
> 
After reading you news posting I had to go try this command on
my system and it work Ok for me, but then I am using C. E. Chew's
version of ls.c.  There was lot of trouble getting the IBM-PC
minix compile to accept it but these problem are solved now.
I consider this version of ls to be superior to the others and
well the worth the aggravation to get it debuged. I prefer it
over all the ls submitted to the news net, even over the V1.5.0

Robert R. Hall
hall@nosc.mil