Add support for the XCU5 -p option (-F restricted to directories).
This commit is contained in:
parent
60307f0ef1
commit
b424b8fe8c
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: ls.1,v 1.22 1999/02/12 14:35:49 kleink Exp $
|
||||
.\" $NetBSD: ls.1,v 1.23 1999/02/17 15:28:08 kleink Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1980, 1990, 1991, 1993, 1994
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
|
@ -139,6 +139,8 @@ is displayed.
|
|||
(See
|
||||
.Xr chflags 1
|
||||
for a list of possible flags and their meanings.)
|
||||
.It Fl p
|
||||
Display a slash (/) immediately after each pathname that is a directory.
|
||||
.It Fl q
|
||||
Force printing of non-graphic characters in file names as
|
||||
the character `?'; this is the default when output is to a terminal.
|
||||
|
|
14
bin/ls/ls.c
14
bin/ls/ls.c
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ls.c,v 1.35 1999/02/12 14:35:49 kleink Exp $ */
|
||||
/* $NetBSD: ls.c,v 1.36 1999/02/17 15:28:09 kleink Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993, 1994
|
||||
|
@ -46,7 +46,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993, 1994\n\
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)ls.c 8.7 (Berkeley) 8/5/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: ls.c,v 1.35 1999/02/12 14:35:49 kleink Exp $");
|
||||
__RCSID("$NetBSD: ls.c,v 1.36 1999/02/17 15:28:09 kleink Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
@ -106,6 +106,7 @@ int f_size; /* list size in short listing */
|
|||
int f_statustime; /* use time of last mode change */
|
||||
int f_stream; /* stream format */
|
||||
int f_type; /* add type character for non-regular files */
|
||||
int f_typedir; /* add type character for directories */
|
||||
int f_whiteout; /* show whiteout entries */
|
||||
|
||||
int
|
||||
|
@ -135,7 +136,7 @@ main(argc, argv)
|
|||
f_listdot = 1;
|
||||
|
||||
fts_options = FTS_PHYSICAL;
|
||||
while ((ch = getopt(argc, argv, "1ACFLRSTWacdfgiklmnoqrstux")) != -1) {
|
||||
while ((ch = getopt(argc, argv, "1ACFLRSTWacdfgiklmnopqrstux")) != -1) {
|
||||
switch (ch) {
|
||||
/*
|
||||
* The -1, -C, -l, -m and -x options all override each other so
|
||||
|
@ -211,6 +212,9 @@ main(argc, argv)
|
|||
case 'o':
|
||||
f_flags = 1;
|
||||
break;
|
||||
case 'p':
|
||||
f_typedir = 1;
|
||||
break;
|
||||
case 'q':
|
||||
f_nonprint = 1;
|
||||
break;
|
||||
|
@ -241,10 +245,10 @@ main(argc, argv)
|
|||
argv += optind;
|
||||
|
||||
/*
|
||||
* If not -F, -i, -l, -S, -s or -t options, don't require stat
|
||||
* If not -F, -i, -l, -p, -S, -s or -t options, don't require stat
|
||||
* information.
|
||||
*/
|
||||
if (!f_inode && !f_longform && !f_size && !f_type &&
|
||||
if (!f_inode && !f_longform && !f_size && !f_type && !f_typedir &&
|
||||
sortkey == BY_NAME)
|
||||
fts_options |= FTS_NOSTAT;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ls.h,v 1.9 1998/05/16 15:12:26 lukem Exp $ */
|
||||
/* $NetBSD: ls.h,v 1.10 1999/02/17 15:28:09 kleink Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993
|
||||
|
@ -50,6 +50,7 @@ extern int f_sectime; /* print the real time for all files */
|
|||
extern int f_size; /* list size in short listing */
|
||||
extern int f_statustime; /* use time of last mode change */
|
||||
extern int f_type; /* add type character for non-regular files */
|
||||
extern int f_typedir; /* add type character for directories */
|
||||
|
||||
typedef struct {
|
||||
FTSENT *list;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: print.c,v 1.25 1999/02/12 14:35:49 kleink Exp $ */
|
||||
/* $NetBSD: print.c,v 1.26 1999/02/17 15:28:09 kleink Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993, 1994
|
||||
|
@ -41,7 +41,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)print.c 8.5 (Berkeley) 7/28/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: print.c,v 1.25 1999/02/12 14:35:49 kleink Exp $");
|
||||
__RCSID("$NetBSD: print.c,v 1.26 1999/02/17 15:28:09 kleink Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
@ -133,7 +133,7 @@ printlong(dp)
|
|||
else
|
||||
printtime(sp->st_mtime);
|
||||
(void)printf("%s", p->fts_name);
|
||||
if (f_type)
|
||||
if (f_type || (f_typedir && S_ISDIR(sp->st_mode)))
|
||||
(void)printtype(sp->st_mode);
|
||||
if (S_ISLNK(sp->st_mode))
|
||||
printlink(p);
|
||||
|
@ -157,7 +157,7 @@ printcol(dp)
|
|||
colwidth += dp->s_inode + 1;
|
||||
if (f_size)
|
||||
colwidth += dp->s_block + 1;
|
||||
if (f_type)
|
||||
if (f_type || f_typedir)
|
||||
colwidth += 1;
|
||||
|
||||
colwidth += 1;
|
||||
|
@ -219,7 +219,7 @@ printacol(dp)
|
|||
colwidth += dp->s_inode + 1;
|
||||
if (f_size)
|
||||
colwidth += dp->s_block + 1;
|
||||
if (f_type)
|
||||
if (f_type || f_typedir)
|
||||
colwidth += 1;
|
||||
|
||||
colwidth += 1;
|
||||
|
@ -303,7 +303,7 @@ printaname(p, inodefield, sizefield)
|
|||
chcnt += printf("%*llu ", sizefield,
|
||||
(long long)howmany(sp->st_blocks, blocksize));
|
||||
chcnt += printf("%s", p->fts_name);
|
||||
if (f_type)
|
||||
if (f_type || (f_typedir && S_ISDIR(sp->st_mode)))
|
||||
chcnt += printtype(sp->st_mode);
|
||||
return (chcnt);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: util.c,v 1.16 1999/02/12 14:35:49 kleink Exp $ */
|
||||
/* $NetBSD: util.c,v 1.17 1999/02/17 15:28:09 kleink Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993, 1994
|
||||
|
@ -41,7 +41,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)util.c 8.5 (Berkeley) 4/28/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: util.c,v 1.16 1999/02/12 14:35:49 kleink Exp $");
|
||||
__RCSID("$NetBSD: util.c,v 1.17 1999/02/17 15:28:09 kleink Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
@ -74,7 +74,7 @@ void
|
|||
usage()
|
||||
{
|
||||
(void)fprintf(stderr,
|
||||
"usage: ls [-1ACFLRSTWacdfgiklmnoqrstux] [file ...]\n");
|
||||
"usage: ls [-1ACFLRSTWacdfgiklmnopqrstux] [file ...]\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue