summaryrefslogtreecommitdiffstats
path: root/bin/ls/ls.c
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>1998-04-21 22:02:01 +0000
committerdes <des@FreeBSD.org>1998-04-21 22:02:01 +0000
commit88ece5135ae0350444a49333e5f9119ee4cd28a9 (patch)
tree313376d3aae434f5bf31c1557832c5f36663816a /bin/ls/ls.c
parent7914b665ae42ef64075912c42a8457c8d4fadff2 (diff)
downloadFreeBSD-src-88ece5135ae0350444a49333e5f9119ee4cd28a9.zip
FreeBSD-src-88ece5135ae0350444a49333e5f9119ee4cd28a9.tar.gz
Added -b option to display unprintables in octal.
PR: 1315
Diffstat (limited to 'bin/ls/ls.c')
-rw-r--r--bin/ls/ls.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/bin/ls/ls.c b/bin/ls/ls.c
index 768af2d..5c6da7e 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.16 1997/08/07 22:28:23 steve Exp $";
+ "$Id: ls.c,v 1.17 1997/09/18 06:42:27 sef Exp $";
#endif
#endif /* not lint */
@@ -88,6 +88,7 @@ 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 */
int f_recursive; /* ls subdirectories also */
int f_reversesort; /* reverse whatever sort is used */
int f_sectime; /* print the real time for all files */
@@ -135,7 +136,7 @@ main(argc, argv)
f_listdot = 1;
fts_options = FTS_PHYSICAL;
- while ((ch = getopt(argc, argv, "1ACFLRTWacdfgikloqrstu")) != -1) {
+ while ((ch = getopt(argc, argv, "1ACFLRTWabcdfgikloqrstu")) != -1) {
switch (ch) {
/*
* The -1, -C and -l options all override each other so shell
@@ -199,6 +200,7 @@ main(argc, argv)
break;
case 'q':
f_nonprint = 1;
+ f_octal = 0;
break;
case 'r':
f_reversesort = 1;
@@ -215,6 +217,10 @@ main(argc, argv)
case 'W':
f_whiteout = 1;
break;
+ case 'b':
+ f_octal = 1;
+ f_nonprint = 0;
+ break;
default:
case '?':
usage();
@@ -426,6 +432,10 @@ display(p, list)
prcopy(cur->fts_name, cur->fts_name, cur->fts_namelen);
if (cur->fts_namelen > maxlen)
maxlen = cur->fts_namelen;
+ if (f_octal) {
+ int t = len_octal(cur->fts_name, cur->fts_namelen);
+ if (t > maxlen) maxlen = t;
+ }
if (needstats) {
sp = cur->fts_statp;
if (sp->st_blocks > maxblock)
OpenPOWER on IntegriCloud