[comp.os.minix] ls Version 2 - Part 1 of 2

cechew@bruce.OZ (Earl Chew) (10/09/89)

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 1 (of 2)."
# Contents:  MANIFEST ls.doc ls.man makefile
# Wrapped by cechew@bruce on Mon Oct  9 19:57:50 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'MANIFEST'\"
else
echo shar: Extracting \"'MANIFEST'\" \(311 characters\)
sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
X   File Name		Archive #	Description
X-----------------------------------------------------------
X MANIFEST                   1	This shipping list
X ls.c                       2	Source code
X ls.doc                     1	Man page
X ls.man                     1	Man page source
X makefile                   1	Makefile
END_OF_FILE
if test 311 -ne `wc -c <'MANIFEST'`; then
    echo shar: \"'MANIFEST'\" unpacked with wrong size!
fi
# end of 'MANIFEST'
fi
if test -f 'ls.doc' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'ls.doc'\"
else
echo shar: Extracting \"'ls.doc'\" \(6169 characters\)
sed "s/^X//" >'ls.doc' <<'END_OF_FILE'
X
X
X
XLS(1)               Minix Programmer's Manual               LS(1)
X
X
X
XNAME
X     ls - list contents of directory
X
XSYNOPSIS
X     ls [ -abdfgilmnopqrstux1ACFLR ] [names]
X
XDESCRIPTION
X     For each directory argument, ls lists the contents of the
X     directory; for each file argument, ls repeats its name and
X     any other information requested. The output is sorted alpha-
X     betically by default. When no argument is given, the current
X     directory is listed. When several arguments are given, the
X     arguments are first sorted approriately, but the file argu-
X     ments are processed before directories and their contents.
X
X     There are two major listing formats. The default format is
X     to list one entry per line, and the -C and -x options enable
X     multi-column formats.  An 80 column output device is assumed
X     for the multi-column formats.
X
X     In order to make the output readable, ls permits the user
X     use the environment variable LSOPTS to hold options which
X     will be used, in addition to those specified on the command
X     line, if the output is to a terminal. For example, a useful
X     setting to have in .profile is:
X
X          LSOPTS=CF ; export LSOPTS
X
X     The options available are:
X
X     -a  List all entries; entries beginning with a period (.)
X         are usually not listed.
X
X     -b  Force printing of nongraphic characters to be in the
X         octal \ddd notation.
X
X     -d  If an argument is a directory, list only its name (not
X         its contents).
X
X     -f  Force each argument to be interpreted as a directory,
X         and list the name found in each slot. This option turns
X         off -l, -n, -o, -F, -p, -t, -s and -r, and turns on -a;
X         the order is the order in which the entries appear in
X         the directory.
X
X     -g  The same as -l, except that the group is printed but not
X         the owner.
X
X     -i  For each file, print the inode number in the first
X         column of the report.
X
X     -l  List in long format giving mode, number of links, owner,
X
X
X
XPrinted 9/26/89               MINIX                             1
X
X
X
X
X
X
XLS(1)               Minix Programmer's Manual               LS(1)
X
X
X
X         group, size in bytes, and time of last modification for
X         each file. If the file is a special file, the size field
X         will instead contain the major and minor device numbers
X         rather than a size. If the file is a symbolic link, the
X         link is printed preceded by an arrow.
X
X     -m  Stream output format. The output is written across the
X         page with no attempt to format it into even columns.
X
X     -n  The same as -l, except that the owner's uid and group's
X         gid numbers are printed, rather than the associated
X         character strings.
X
X     -o  The same as -l, except that the owner is not printed but
X         not the group.
X
X     -p  Put a slash after each filename if that file is a direc-
X         tory.
X
X     -q  Force printing of nongraphic characters in filenames as
X         the character ?.
X
X     -r  Reverse the order of the sort to obtain either a reverse
X         alphabetic or oldest first as appropriate.
X
X     -s  Give the size in kilobytes, including indirect blocks,
X         for each entry.
X
X     -t  Sort by time stamp (latest first) instead of by name.
X         The time indicated is the last modification time.
X
X     -x  Multicolumn output with entries sorted across rather
X         than down the page.
X
X     -1  Force one entry per line to be printed. This is the
X         default when output is not to a terminal.
X
X     -A  List all entries including those beginning with a
X         period, except for . and .. which are not listed. This
X         option is automatically turned on when root invokes ls.
X
X     -C  Multicolumn output with entries sorted down the columns.
X
X     -F  Cause directories to be marked with a trailing /, sym-
X         bolic links with a trailing @, sockets with a trailing
X         =,  and executables with a trailing *.
X
X     -L  If the file is a symbolic link, print information about
X         the file indicated by the link rather than the link
X         itself.
X
X     -R  Recursively list subdirectories encountered.
X
X
X
XPrinted 9/26/89               MINIX                             2
X
X
X
X
X
X
XLS(1)               Minix Programmer's Manual               LS(1)
X
X
X
X     The mode printed under the -l option consists of 10 charac-
X     ters that are interpreted as follows:
X
X     The first character is:
X          d    if the entry is a directory
X          b    if the entry is a block special file
X          c    if the entry is a character special file
X          p    if the entry is a FIFO special file
X          l    if the entry is a symbolic link
X          s    if the entry is a socket
X          -    if the entry is an ordinary file
X
X     The next 9 characters are interpreted as three sets of three
X     bits each. The first set refers to the owner's permissions;
X     the next to permissions of those in the user group of the
X     file; and the last to all others. Within each set, the three
X     characters indicate permission to read, to write and to exe-
X     cute the file as a program, repectively. For a directory,
X     execute permission is interpreted to mean permission to
X     search the directory for a specified file.
X
X     The permissions within each section are indicated as fol-
X     lows:
X          r    the file is readable
X          w    the file is writable
X          x    the file is executable
X          -    the indicated permission is not granted
X          s    the set-uid or set-gid and the execute bit is on
X          S    as with s but the execute bit is off
X
X     When the sizes of the files in a directory are listed, a
X     total count of kilobytes, including indirect blocks is
X     printed.
X
XENVIRONMENT
X     LSOPTS         default options for output to a terminal
X
XFILES
X     /etc/passwd    uids for ls -l and ls -o
X     /etc/group     gids for ls -l and ls -g
X
XSEE ALSO
X     sh(1)
X
XBUGS
X     Non graphic characters will confuse the multicolumn output
X     routines.
X
X
X
X
X
X
X
X
XPrinted 9/26/89               MINIX                             3
X
X
X
END_OF_FILE
if test 6169 -ne `wc -c <'ls.doc'`; then
    echo shar: \"'ls.doc'\" unpacked with wrong size!
fi
# end of 'ls.doc'
fi
if test -f 'ls.man' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'ls.man'\"
else
echo shar: Extracting \"'ls.man'\" \(5244 characters\)
sed "s/^X//" >'ls.man' <<'END_OF_FILE'
X.TH LS 1 MINIX "" "Minix Programmer's Manual"
X.SH NAME
Xls - list contents of directory
X.SH SYNOPSIS
X.B ls
X[
X.B -abdfgilmnopqrstux1ACFLR
X] [names]
X.SH DESCRIPTION
XFor each directory argument,
X.B ls
Xlists the contents of the directory; for each file argument,
X.B ls
Xrepeats its name and any other information requested. The output is sorted
Xalphabetically by default. When no argument is given, the current directory
Xis listed. When several arguments are given, the arguments are first sorted
Xapproriately, but the file arguments are processed before directories and
Xtheir contents.
X.PP
XThere are two major listing formats. The default format is to list one
Xentry per line, and the \-C and \-x options enable multi-column formats.
XAn 80 column output device is assumed for the multi-column formats.
X.PP
XIn order to make the output readable,
X.B ls
Xpermits the user use the environment variable
X.B LSOPTS
Xto hold options which will be used, in addition to those specified on the
Xcommand line, if the output is to a terminal. For example, a useful setting
Xto have in .profile is:
X.sp
X	LSOPTS=CF ; export LSOPTS
X.PP
XThe options available are:
X.TP 4
X\-a
XList all entries; entries beginning with a period (.) are usually not listed.
X.TP 4
X\-b
XForce printing of nongraphic characters to be in the octal \\ddd notation.
X.TP 4
X\-d
XIf an argument is a directory, list only its name (not its contents).
X.TP 4
X\-f
XForce each argument to be interpreted as a directory, and list the name
Xfound in each slot. This option turns off \-l, \-n, \-o, \-F, \-p, \-t, \-s and
X\-r, and turns on \-a; the order is the order in which the entries appear
Xin the directory.
X.TP 4
X\-g
XThe same as \-l, except that the group is printed but not the owner.
X.TP 4
X\-i
XFor each file, print the inode number in the first column of the report.
X.TP 4
X\-l
XList in long format giving mode, number of links, owner, group, size in
Xbytes, and time of last modification for each file. If the file is a special
Xfile, the size field will instead contain the major and minor device numbers
Xrather than a size. If the file is a symbolic link, the link is printed
Xpreceded by an arrow.
X.TP 4
X\-m
XStream output format. The output is written across the page with no
Xattempt to format it into even columns.
X.TP 4
X\-n
XThe same as \-l, except that the owner's uid and group's gid numbers are
Xprinted, rather than the associated character strings.
X.TP 4
X\-o
XThe same as \-l, except that the owner is not printed but not the group.
X.TP 4
X\-p
XPut a slash after each filename if that file is a directory.
X.TP 4
X\-q
XForce printing of nongraphic characters in filenames as the character ?.
X.TP 4
X\-r
XReverse the order of the sort to obtain either a reverse alphabetic or
Xoldest first as appropriate.
X.TP 4
X\-s
XGive the size in kilobytes, including indirect blocks, for each entry.
X.TP 4
X\-t
XSort by time stamp (latest first) instead of by name. The time indicated
Xis the last modification time.
X.TP 4
X\-x
XMulticolumn output with entries sorted across rather than down the page.
X.TP 4
X\-1
XForce one entry per line to be printed. This is the default when
Xoutput is not to a terminal.
X.TP 4
X\-A
XList all entries including those beginning with a period, except
Xfor . and .. which are not listed. This option is automatically turned on
Xwhen root invokes ls.
X.TP 4
X\-C
XMulticolumn output with entries sorted down the columns.
X.TP 4
X\-F
XCause directories to be marked with a trailing /, symbolic links
Xwith a trailing @, sockets with a trailing =,  and executables with
Xa trailing *.
X.TP 4
X\-L
XIf the file is a symbolic link, print information about the file indicated
Xby the link rather than the link itself.
X.TP 4
X\-R
XRecursively list subdirectories encountered.
X.PP
XThe mode printed under the \-l option consists of 10 characters that are
Xinterpreted as follows:
X.PP
XThe first character is:
X.br
X	d	if the entry is a directory
X.br
X	b	if the entry is a block special file
X.br
X	c	if the entry is a character special file
X.br
X	p	if the entry is a FIFO special file
X.br
X	l	if the entry is a symbolic link
X.br
X	s	if the entry is a socket
X.br
X	-	if the entry is an ordinary file
X.PP
XThe next 9 characters are interpreted as three sets of three bits each. The
Xfirst set refers to the owner's permissions; the next to permissions of
Xthose in the user group of the file; and the last to all others. Within each
Xset, the three characters indicate permission to read, to write and to
Xexecute the file as a program, repectively. For a directory, execute
Xpermission is interpreted to mean permission to search the directory for a
Xspecified file.
X.PP
XThe permissions within each section are indicated as follows:
X.br
X	r	the file is readable
X.br
X	w	the file is writable
X.br
X	x	the file is executable
X.br
X	-	the indicated permission is not granted
X.br
X	s	the set-uid or set-gid and the execute bit is on
X.br
X	S	as with s but the execute bit is off
X.PP
XWhen the sizes of the files in a directory are listed, a total count of
Xkilobytes, including indirect blocks is printed.
X.SH ENVIRONMENT
XLSOPTS		default options for output to a terminal
X.SH FILES
X/etc/passwd	uids for ls \-l and ls \-o
X.br
X/etc/group	gids for ls \-l and ls \-g
X.SH SEE ALSO
Xsh(1)
X.SH BUGS
XNon graphic characters will confuse the multicolumn output routines.
END_OF_FILE
if test 5244 -ne `wc -c <'ls.man'`; then
    echo shar: \"'ls.man'\" unpacked with wrong size!
fi
# end of 'ls.man'
fi
if test -f 'makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'makefile'\"
else
echo shar: Extracting \"'makefile'\" \(437 characters\)
sed "s/^X//" >'makefile' <<'END_OF_FILE'
XALL=	makefile ls.c ls.doc ls.man
XCFLAGS=	-D_BSD -O
X#
Xls:	ls.o
X	cc -o ls ls.o
Xls.o:	ls.c
X#
Xlint:
X	lint -D_BSD ls.c
X#
Xarc:
X	rm -f ls.arc
X	arc a ls $(ALL)
X#
Xtar:
X	rm -f ls.tar.Z
X	tar cvf - $(ALL) | compress > ls.tar.Z
X#
Xshar:
X	ls $(ALL) | \
X	sed -e 's/^.*\.man$$/&	Man page source/' \
X	    -e 's/^.*\.doc$$/&	Man page/' \
X	    -e 's/^makefile$$/&	Makefile/' \
X	    -e 's/^[0-9a-z_]*\.c$$/&	Source code/' | \
X	makekit -nls. -s40k -oMANIFEST
END_OF_FILE
if test 437 -ne `wc -c <'makefile'`; then
    echo shar: \"'makefile'\" unpacked with wrong size!
fi
# end of 'makefile'
fi
echo shar: End of archive 1 \(of 2\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 2 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked both archives.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
-- 
Earl Chew, Dept of Computer Science, Monash University, Australia 3168
ARPA: cechew%bruce.cs.monash.oz.au@uunet.uu.net  ACS : cechew@bruce.oz
----------------------------------------------------------------------