%%s 3/3/449 %%d D 1.2 04-May-82 16:00:19 tools 2 1 %%c Modified ls.w`ls.r`initls to permit `-l' as a synonym for `-v'. %%c Wayne R. Graves is now immortally bound to the tools! %%s 0/0/0 %%d D 1.1 25-Mar-82 12:08:13 v1.1 1 0 %%c Version 1.1 is the Spring 1982 Distribution of the LBL/Hughes release %%c of the Software Tools Virtual Operating System software and documentation. %%T %%I 1 #-h- cls 723 asc 25-mar-82 08:05:32 v1.1 (sw-tools v1.1) ### CLs Common block for `ls'. common / cls / verbos, dodate, revers, sortit, dirsw, dohead, packit, scrat(FILENAMESIZE), fmtctl(MAXLINE) integer verbos # verbose switch - init NO ; set by -vt integer dodate # dodate switch - init NO ; set by -t integer revers # revers switch - init NO ; set by -r integer sortit # if need to sort entries ; init SORTBYDEFAULT # sortit is set to YES if (dodate == YES | # revers == YES) integer dirsw # do directory switch - init NO; set by -d integer dohead # print header on verbose listings; init = NO integer packit # pack non-verbose files in 5 columns; init=YES character scrat # scratch file name character fmtctl # format string - init DEFAULT_FORMAT ; set by -f #-h- ddef 16 asc 25-mar-82 08:05:33 v1.1 (sw-tools v1.1) define(MAKE_D,) %%D 2 #-h- ls.r 6339 asc 25-mar-82 08:05:34 v1.1 (sw-tools v1.1) %%E 2 %%I 2 #-h- ls.r 6367 asc 04-may-82 15:59:13 tools (lblh csam sventek) %%E 2 #-h- defns 817 asc 25-mar-82 08:05:17 v1.1 (sw-tools v1.1) ifdef(MAKE_D) define(DEFAULT_FORMAT,"17n 9c t m p o") define(USAGE_STRING,"usage: d [-1dhnrtv] [-fstring] [pathname] ...") define(HEADER_LINE_1,"FileName FileSize Typ Time last modified ") define(HEADER_LINE_2," Protection Owner@n") define(HEADER_LINE_3,"--------------------------- --- -------------------- ") define(HEADER_LINE_4,"Own-|Grp-|Wor- ---------@n") elsedef define(DEFAULT_FORMAT,"17n p m 6b o") define(USAGE_STRING,"usage: ls [-1dhnrtv] [-fstring] [pathname]...") define(HEADER_LINE_1,"filename protection last modified ") define(HEADER_LINE_2," size owner@n") define(HEADER_LINE_3,"-------- -------------- --------------------") define(HEADER_LINE_4," ------- -----@n@n") enddef define(FLMAX,10) define(RIGHT_MARGIN,80) define(SORTBYDEFAULT,NO) #-h- main 3037 asc 25-mar-82 08:05:18 v1.1 (sw-tools v1.1) ### Ls List directory. (also known as `d') DRIVER(ls) filedes outfil filedes create, open, opendr # function(s) integer depth, desc, i, j, level, n, nxtcol, ptr(MAXDIRECTS), status integer pat(MAXPAT) integer gdrprm, getarg, getlin, getpat, length, match # function(s) character buf(MAXLINE), defpat(2), file(FILENAMESIZE) character obuf(MAXLINE), ppath(FILENAMESIZE) include cls string dirpat "?*/" string head1 HEADER_LINE_1 string head2 HEADER_LINE_2 string head3 HEADER_LINE_3 string head4 HEADER_LINE_4 data defpat / '%', EOS / call initls(file) level = 0 if( dohead == YES ) { call putlin( head1, STDOUT) call putlin( head2, STDOUT) call putlin( head3, STDOUT) call putlin( head4, STDOUT) } if( packit == YES ) call inpack( nxtcol, RIGHT_MARGIN, obuf, STDOUT) repeat { level = level + 1 status = getarg( level, ppath, FILENAMESIZE) if( status == EOF & level > 1 ) break else if( status == EOF ) call gwdir( ppath, PATH) call strcpy( defpat, file) if( opendr( ppath, desc) == ERR ) { call strcpy( ppath, buf) call mkpath( buf, ppath) if( ppath(1) == EOS ) # Path doesn't exist (dpm 15-Oct-81) call cant(buf) call exppth( ppath, depth, ptr, buf) j = ptr(depth) junk = gtftok( ppath, j, file) j = ptr(depth) ppath(j) = EOS if( opendr( ppath, desc) == ERR ) call cant(ppath) } if( dirsw == YES ) call concat( file, dirpat, file) call fold(file) if( getpat( file, pat) == ERR ) call error( "? Illegal pattern." ) if( sortit == YES ) { outfil = create( scrat, WRITE) if( outfil == ERR ) call error( "? Error creating temporary file." ) } else outfil = STDOUT while( gdrprm( desc, file) != EOF ) { i = length(file) + 1 file(i) = '@n' file( i + 1 ) = EOS call fold(file) if( match( file, pat) == YES ) { i = length(file) file(i) = EOS if( packit == YES & outfil == STDOUT ) call dopack( file, nxtcol, RIGHT_MARGIN, obuf, STDOUT) else { if( verbos == YES ) { call gdraux( desc, file, buf, ppath, fmtctl) if( dodate == YES ) call putlin( ppath, outfil) call putlin( buf, outfil) } else call putlin( file, outfil) call putch( '@n', outfil) } } } call closdr(desc) if( sortit == YES ) { call close(outfil) call sortls( scrat, revers, buf) outfil = open( scrat, READ) if( outfil == ERR ) call error( "Error in opening sorted scratch file." ) while( getlin( buf, outfil) != EOF ) { if( dodate == YES ) i = TCOLWIDTH + 1 else i = 1 if( packit == YES ) { i = 1 junk = getwrd( buf, i, file) call dopack( file, nxtcol, RIGHT_MARGIN, obuf, STDOUT) } else call putlin( buf(i), STDOUT) } call close(outfil) } if( packit == YES ) call flpack( nxtcol, RIGHT_MARGIN, obuf, STDOUT) } call endls DRETURN end #-h- endls 129 asc 25-mar-82 08:05:19 v1.1 (sw-tools v1.1) ### EndLs Cleanup routine for `ls'. subroutine endls integer junk integer remove include cls junk = remove(scrat) return end %%D 2 #-h- initls 1232 asc 25-mar-82 08:05:20 v1.1 (sw-tools v1.1) %%E 2 %%I 2 #-h- initls 1255 asc 04-may-82 15:56:24 tools (lblh csam sventek) %%E 2 subroutine initls(arg) integer i, getarg, index, isatty character arg(FILENAMESIZE) include cls string dflfmt DEFAULT_FORMAT string usestr USAGE_STRING call query(usestr) verbos = NO dohead = NO dodate = NO revers = NO dirsw = NO packit = isatty(STDOUT) sortit = SORTBYDEFAULT call strcpy( dflfmt, fmtctl) for( i = 1 ; getarg( i, arg, FILENAMESIZE) != EOF ; i = i + 1 ) { call fold(arg) if( arg(1) == '-' ) { if( index( arg, 'f') > 0 ) { call scopy( arg, 3, fmtctl, 1) verbos = YES } else { %%D 2 if( index( arg, 'v') > 0 ) %%E 2 %%I 2 if( index( arg, 'v') > 0 | index( arg, 'l') > 0) %%E 2 verbos = YES if( index( arg, 'h') > 0 ) dohead = YES if( index( arg, 't') > 0 ) dodate = YES if( index( arg, 'r') > 0 ) revers = YES if( index( arg, 'n') > 0 & SORTBYDEFAULT == NO ) sortit = YES # sort by name if( index( arg, 'd') > 0 ) dirsw = YES if( index( arg, '1') > 0 ) packit = NO } call delarg(i) i = i - 1 } } if( dodate == YES ) verbos = YES if( dodate == YES | revers == YES ) sortit = YES if( verbos == NO ) dohead = NO else packit = NO # packing impossible in verbose mode if( sortit == YES ) call scratf( ls0, scrat) return end #-h- sortls 759 asc 25-mar-82 08:05:21 v1.1 (sw-tools v1.1) ### SortLs Sort routine for `ls'. subroutine sortls( file, revers, buf) character buf(ARB), descr(PIDSIZE), file(ARB), proc(FILENAMESIZE) character spath(arith(FILENAMESIZE,*,3)) integer i, revers integer loccom, spawn # function(s) string suffix IMAGE_SUFFIX string pluso " +o" string mr " -r" string sort "sort" i = 1 call stcopy( sort, 1, buf, i) call chcopy( ' ', buf, i) call stcopy( file, 1, buf, i) call stcopy( pluso, 1, buf, i) call stcopy( file, 1, buf, i) if( revers == YES ) call stcopy( mr, 1, buf, i) buf(i) = EOS call impath(spath) if( loccom( sort, spath, suffix, proc) != BINARY ) call error( "? Can't locate SORT image file." ) if( spawn( proc, buf, descr, WAIT) == ERR ) call error( "? Error in spawning SORT" ) return end #-h- ls.fmt 2028 asc 25-mar-82 08:05:36 v1.1 (sw-tools v1.1) .so ~bin/manhdr .hd Ls (1) 27-Jul-81 list contents of directory .sy ls [-1dhnrtv] [-fstring] [pathname] ... .ds Ls lists information about each file argument. When no argument is given, the default directory is listed. The file arguments may include any of the legal regular expressions described in the man entry for the editor, with the added feature that the comparisons will be case insensitive. By default, the files are listed in the order in which they are found in the directory. There are seven options: .in +3 .ti -3 -1 force single column output to the terminal. The default is multi-column output to the terminal, single to a disk file. .ti -3 -d print only directory files found in this directory .ti -3 -h print a header at the top of verbose listings .ti -3 -n sort the directory by name .ti -3 -v list in verbose format .ti -3 -t sort by time modified (oldest first) .ti -3 -r reverse the sense of the sort .ti -3 -f use `string' to specify the output format as follows: .in +3 b size of file in blocks (normally 512 characters) c size of file in characters m modification date and time (dd-mmm-yy hh:mm:ss) n filename o file owner's username p protection codes (oooo|gggg|wwww) t file type (asc|bin|dir) .in -3 The `b', `c', `n' and `o' options accept an integer prefix which specifies the field width to be used. The verbose option formats its output as if you had specified "-f17n p m 6b o" as a format string. It is necessary to surround the string (including the `-f') with quotes if it contains any BLANKs or TABs. .in -3 .ex .fi The following command will cause all of the files which contain the string tst anywhere in the file name to be deleted: .nf .in +3 % ls tst | args rm .in -3 .fl lstemp1, lstemp2 .au Ls was written by Joe Sventek. The `-f' option was added by Dave Martin. .sa ed - text editor for description of regular expressions .br args - argument exploder .br d - directory lister (with different default format) .br fd - fast directory lister in sort order #-h- d.fmt 2024 asc 25-mar-82 08:05:38 v1.1 (sw-tools v1.1) .so ~bin/manhdr .hd D (1) 27-Jul-81 list contents of directory .sy d [-1dhnrtv] [-fstring] [pathname] ... .ds D lists information about each file argument. When no argument is given, the default directory is listed. The file arguments may include any of the legal regular expressions described in the man entry for the editor, with the added feature that the comparisons will be case insensitive. By default, the files are listed in the order in which they are found in the directory. There are seven options: .in +3 .ti -3 -1 force single column output to the terminal. The default is multi-column output to the terminal, single to a disk file. .ti -3 -d print only directory files found in this directory .ti -3 -h print a header at the top of verbose listings .ti -3 -n sort the directory by name .ti -3 -v list in verbose format .ti -3 -t sort by time modified (oldest first) .ti -3 -r reverse the sense of the sort .ti -3 -f use `string' to specify the output format as follows: .in +3 b size of file in blocks (normally 512 characters) c size of file in characters m modification date and time (dd-mmm-yy hh:mm:ss) n filename o file owner's username p protection codes (oooo|gggg|wwww) t file type (asc|bin|dir) .in -3 The `b', `c', `n' and `o' options accept an integer prefix which specifies the field width to be used. The verbose option formats its output as if you had specified "-f17n 9c t m p o" as a format string. It is necessary to surround the string (including the `-f') with quotes if it contains any BLANKs or TABs. .in -3 .ex .fi The following command will cause all of the files which contain the string tst anywhere in the file name to be deleted: .nf .in +3 % d tst | args rm .in -3 .fl lstemp1, lstemp2 .au Ls was written by Joe Sventek. The `-f' option was added by Dave Martin. .sa ed - text editor for description of regular expressions .br args - argument exploder .br ls - directory lister (with different default format) .br fd - fast directory lister in sort order %%E 1