summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>1998-04-24 12:43:26 +0000
committerdes <des@FreeBSD.org>1998-04-24 12:43:26 +0000
commit7f8983e5f50864be87a5d978f4c4b46e8c1b7591 (patch)
tree4ac5da9a8bccd136cbb8d25743982b314a2cb5c4 /bin
parent8047e5cea0b71ae987d9b5d875ebbd2e416bc4cc (diff)
downloadFreeBSD-src-7f8983e5f50864be87a5d978f4c4b46e8c1b7591.zip
FreeBSD-src-7f8983e5f50864be87a5d978f4c4b46e8c1b7591.tar.gz
o Removed two unused variables (f_dirname and f_newline) in ls.c
o Added the -H and -P options for treatment of symbolic links. o Removed the #ifdef BSD4_4_LITE, since it does not seem to do anything useful o Fixed up prn_octal() so its output looks more like that of AT&T Unices when -b is given. The next two lines apply only to the first two changes above: PR: bin/6140 Submitted by: Max Euston
Diffstat (limited to 'bin')
-rw-r--r--bin/ls/ls.150
-rw-r--r--bin/ls/ls.c14
-rw-r--r--bin/ls/util.c21
3 files changed, 58 insertions, 27 deletions
diff --git a/bin/ls/ls.1 b/bin/ls/ls.1
index 945ac7c..c930c09 100644
--- a/bin/ls/ls.1
+++ b/bin/ls/ls.1
@@ -33,7 +33,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)ls.1 8.7 (Berkeley) 7/29/94
-.\" $Id: ls.1,v 1.17 1998/04/21 22:01:58 des Exp $
+.\" $Id: ls.1,v 1.18 1998/04/24 07:49:46 des Exp $
.\"
.Dd July 29, 1994
.Dt LS 1
@@ -43,7 +43,7 @@
.Nd list directory contents
.Sh SYNOPSIS
.Nm ls
-.Op Fl ?ABCFLRTWabcdfgikloqrstu1
+.Op Fl ?ABCFHLPRTWabcdfgikloqrstu1
.Op Ar file ...
.Sh DESCRIPTION
For each operand that names a
@@ -92,9 +92,26 @@ an equals sign (=) after each socket,
a percent sign (%) after each whiteout,
and a vertical bar (|) after each that is a
.Tn FIFO .
+.It Fl H
+Symbolic links on the command line are followed. This option is assumed if
+none of the
+.Fl F ,
+.Fl d ,
+or
+.Fl l
+options are specified.
.It Fl L
If argument is a symbolic link, list the file or directory the link references
-rather than the link itself.
+rather than the link itself. This option cancels the
+.Fl P
+option.
+.It Fl P
+If argument is a symbolic link, list the link itself rather than the
+object the link references. This option cancels the
+.Fl H
+and
+.Fl L
+options.
.It Fl R
Recursively list subdirectories encountered.
.It Fl T
@@ -112,8 +129,7 @@ but use C escape codes whenever possible.
.It Fl c
Use time when file status was last changed for sorting or printing.
.It Fl d
-Directories are listed as plain files (not searched recursively) and
-symbolic links in the argument list are not indirected through.
+Directories are listed as plain files (not searched recursively).
.It Fl f
Output is not sorted.
.It Fl g
@@ -129,7 +145,7 @@ For each file, print the file's file serial number (inode number).
If the
.Fl s
option is specified, print the file size allocation in kilobytes,
-not blocks.
+not blocks. This option overrides the environment variable BLOCKSIZE.
.It Fl l
(The lowercase letter ``ell.'') List in long format. (See below.)
If the output is to a terminal, a total sum for all the file
@@ -176,12 +192,28 @@ options all override each other; the last one specified determines
the format used.
.Pp
The
-.Fl c ,
+.Fl c
and
.Fl u
options override each other; the last one specified determines
the file time used.
.Pp
+The
+.Fl B ,
+.Fl b
+and
+.Fl q
+options all override each other; the last one specified determines
+the format used for non-printable characters.
+.Pp
+The
+.Fl H,
+.Fl L
+and
+.Fl P
+options all override each other (either partially or fully); they
+are applied in the order specified.
+.Pp
By default,
.Nm ls
lists one entry per line to standard
@@ -363,3 +395,7 @@ The
function is expected to be a superset of the
.St -p1003.2
specification.
+.Sh BUGS
+To maintain backward compatibility, the relationships between the many
+options is quite complex.
+
diff --git a/bin/ls/ls.c b/bin/ls/ls.c
index 7fdad3d..5a6561d 100644
--- a/bin/ls/ls.c
+++ b/bin/ls/ls.c
@@ -45,7 +45,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)ls.c 8.5 (Berkeley) 4/2/94";
#else
static const char rcsid[] =
- "$Id: ls.c,v 1.18 1998/04/21 22:02:00 des Exp $";
+ "$Id: ls.c,v 1.19 1998/04/24 07:49:47 des Exp $";
#endif
#endif /* not lint */
@@ -85,7 +85,6 @@ int f_kblocks; /* print size in kilobytes */
int f_listdir; /* list actual directory, not contents */
int f_listdot; /* list files beginning with . */
int f_longform; /* long listing format */
-int f_newline; /* if precede with newline */
int f_nonprint; /* show unprintables as ? */
int f_nosort; /* don't sort output */
int f_octal; /* show unprintables as \xxx */
@@ -96,7 +95,6 @@ int f_sectime; /* print the real time for all files */
int f_singlecol; /* use single column output */
int f_size; /* list size in short listing */
int f_statustime; /* use time of last mode change */
-int f_dirname; /* if precede with directory name */
int f_timesort; /* sort by time vice name */
int f_type; /* add type character for non-regular files */
int f_whiteout; /* show whiteout entries */
@@ -137,7 +135,7 @@ main(argc, argv)
f_listdot = 1;
fts_options = FTS_PHYSICAL;
- while ((ch = getopt(argc, argv, "?1ABCFLRTWabcdfgikloqrstu")) != -1) {
+ while ((ch = getopt(argc, argv, "?1ABCFHLPRTWabcdfgikloqrstu")) != -1) {
switch (ch) {
/*
* The -1, -C and -l options all override each other so shell
@@ -172,10 +170,18 @@ main(argc, argv)
case 'F':
f_type = 1;
break;
+ case 'H':
+ fts_options |= FTS_COMFOLLOW;
+ break;
case 'L':
fts_options &= ~FTS_PHYSICAL;
fts_options |= FTS_LOGICAL;
break;
+ case 'P':
+ fts_options &= ~FTS_COMFOLLOW;
+ fts_options &= ~FTS_LOGICAL;
+ fts_options |= FTS_PHYSICAL;
+ break;
case 'R':
f_recursive = 1;
break;
diff --git a/bin/ls/util.c b/bin/ls/util.c
index f72ef6c..3d16088 100644
--- a/bin/ls/util.c
+++ b/bin/ls/util.c
@@ -39,7 +39,7 @@
static char sccsid[] = "@(#)util.c 8.3 (Berkeley) 4/2/94";
#else
static const char rcsid[] =
- "$Id: util.c,v 1.12 1998/04/21 22:02:01 des Exp $";
+ "$Id: util.c,v 1.13 1998/04/24 07:49:51 des Exp $";
#endif
#endif /* not lint */
@@ -103,22 +103,14 @@ prn_octal(s)
while ((ch = *s++))
{
- if (isprint(ch)) putchar(ch), len++;
+ if (isprint(ch) && (ch != '\"') && (ch != '\\'))
+ putchar(ch), len++;
else if (f_octal_escape) {
putchar('\\');
switch (ch) {
- case 0:
- putchar('0');
- break;
case '\\':
putchar('\\');
break;
- case '\?':
- putchar('?');
- break;
- case '\'':
- putchar('\'');
- break;
case '\"':
putchar('"');
break;
@@ -166,10 +158,7 @@ prn_octal(s)
void
usage()
{
-#ifdef BSD4_4_LITE
- (void)fprintf(stderr, "usage: ls [-1ACFLRTacdfiklqrstu] [file ...]\n");
-#else
- (void)fprintf(stderr, "usage: ls [-ACFLRTWacdfgikloqrstu1] [file ...]\n");
-#endif
+ (void)fprintf(stderr, "usage: ls [-?ACFHLPRTWacdfgikloqrstu1]"
+ " [file ...]\n");
exit(1);
}
OpenPOWER on IntegriCloud