From: Larry A. Shurr Lattice, Inc. P. O. Box 3148 Glen Ellyn, IL 60138 To: Ed Nather and all other interested parties Subj: "New" and "Improved" ls utility I was especially glad to run across this utility from my old alma mater (University of Texas at Austin). I liked it a and, being the kind of person I am, couldn't resist making a few "improvements" (hope you don't mind, Ed). It works as before with the additions described below: Apology and disclaimer: I have never met any UNIX system, so I find it difficult to "keep faith" with the behavior of UNIX utilities as I do not know what I am doing. If I have done something "wrong", please forgive me. Naturally, I offer no warranty of any kind on this program. It is, as its prede- cessor was, placed in the public domain and is offered "as is." Like its predecessor, however, it appears to be largely bug free and "safe" to use. New or changed aspects of ls: 1) Use of Lattice C: Naturally, I prefer to use Lattice C, under which ls would not orginally compile. In converting it for use with Lattice C, I hope I have not "broken" it with respect to alternative (ahem -- Brand X) C compilers. 2) Use of environment variables: Default settings for options may now be changed by defining MS-DOS environment variables: LSALL list all files option LSCOLM one column listing option LSDU disk usage option LSID always identify directory option LSLONG long listing option LSMORE pause for more option LSRSORT reverse sort direction option LSTSORT sort by time option For convenience in discussion, I refer to these as "dynamic defaults." To set a default to "ON" use the MS-DOS command: set =1 That's all there is to it! You can set a default to "OFF" with set =0 but this is unnecessary. By omitting any definition for the variable it will be assumed to be set to "OFF". The corresponding command line options always reverse the default as set by the environment variable. For example, if LSALL = 0 (OFF), then the -a option will turn the "list all" option ON. Conversely, if LSALL = 1 (ON), then the -a option will turn the "list all" option OFF. Refer to ls.doc for more information. 3) "Pause for more" is now an option: Previously, the listing was always paused after each 22 lines when output was to the console. Now, this option may be set using -m on the command line or by setting the LSMORE default variable to 1. 4) Heapsort code added: Lattice C does not have the qsort() function available in CI86 and DeSmet C. Therefore, I have supplied a sort function. My sort uses the heapsort algorithm and can be readily modified for your own purposes. I ask that you credit me in anything you use it with and that you help keep the goodies coming. Heapsort is fast (proportional to n*log2(n)) and non-recursive (therefore, no trouble with stack overflow). 5) Help feature added: Specifying the -h option causes a summary of the available options to be printed on the standard error file. In addition to the help summary, the current settings of the dynamic defaults are also displayed. The help summary is also printed if any invalid options are specified. 6) Filename pattern matching on recursive descent: You may specify a filename pattern (i.e., a filename with wild- cards allowed) as part of an argument to ls with the -R option. When you do so, ls will search for all matches for the filename pattern in the directory tree beginning from the specified directory pathname in the argument and produce a display in accordance with the option settings you set or specify. Thus: ls *.asm will search for all files matching "*.asm" in the directory tree commencing from the current directory and ls e:\*.c will search for all the C source files on drive "e:". Thus, among other things, ls may be used as a "find" utility. 7) Sorting for -R option: Directories are sorted and searched in the order selected by your sort settings/options. 8) Full directory paths printed: No matter how the directory path is specified in an ls argument, the fully-extended pathname is displayed, if requested, so that you can always tell exactly what directory is being listed.