summaryrefslogtreecommitdiff
path: root/usr.bin/file
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2002-11-29 00:27:04 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2002-11-29 00:27:04 +0000
commit99328e699f5768ac2189b862432f978ddd7b9114 (patch)
tree01b56da979f49228fa8dc91f11991369970c465e /usr.bin/file
parent6619e255ad78f115148deefee6033ab761d97990 (diff)
Add -b flag (brief mode) like NetBSD and FreeBSD; Ibrahim Khalifa
Diffstat (limited to 'usr.bin/file')
-rw-r--r--usr.bin/file/file.16
-rw-r--r--usr.bin/file/file.c16
2 files changed, 14 insertions, 8 deletions
diff --git a/usr.bin/file/file.1 b/usr.bin/file/file.1
index ca909cdb592..8235f5a0df5 100644
--- a/usr.bin/file/file.1
+++ b/usr.bin/file/file.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: file.1,v 1.16 2002/01/24 19:34:48 mickey Exp $
+.\" $OpenBSD: file.1,v 1.17 2002/11/29 00:27:03 millert Exp $
.\" $FreeBSD: src/usr.bin/file/file.1,v 1.16 2000/03/01 12:19:39 sheldonh Exp $
.Dd July 30, 1997
.Dt FILE 1
@@ -8,7 +8,7 @@
.Nd determine file type
.Sh SYNOPSIS
.Nm file
-.Op Fl vczL
+.Op Fl vbczL
.Op Fl f Ar namefile
.Op Fl m Ar magicfiles
.Ar file Op Ar ...
@@ -126,6 +126,8 @@ of files containing magic numbers.
This can be a single file, or a colon-separated list of files.
.It Fl z
Try to look inside compressed files.
+.It Fl b
+Do not prepend filenames to output lines (brief mode).
.It Fl c
Cause a checking printout of the parsed form of the magic file.
This is usually used in conjunction with
diff --git a/usr.bin/file/file.c b/usr.bin/file/file.c
index a7ec04264e2..7c1bcec6089 100644
--- a/usr.bin/file/file.c
+++ b/usr.bin/file/file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.c,v 1.8 2002/02/16 21:27:46 millert Exp $ */
+/* $OpenBSD: file.c,v 1.9 2002/11/29 00:27:03 millert Exp $ */
/*
* file - find type of a file or files - main program.
@@ -27,7 +27,7 @@
* 4. This notice may not be removed or altered.
*/
#ifndef lint
-static char *moduleid = "$OpenBSD: file.c,v 1.8 2002/02/16 21:27:46 millert Exp $";
+static char *moduleid = "$OpenBSD: file.c,v 1.9 2002/11/29 00:27:03 millert Exp $";
#endif /* lint */
#include <stdio.h>
@@ -55,9 +55,9 @@ static char *moduleid = "$OpenBSD: file.c,v 1.8 2002/02/16 21:27:46 millert Exp
#include "file.h"
#ifdef S_IFLNK
-# define USAGE "Usage: %s [-vczL] [-f namefile] [-m magicfiles] file...\n"
+# define USAGE "Usage: %s [-vbczL] [-f namefile] [-m magicfiles] file...\n"
#else
-# define USAGE "Usage: %s [-vcz] [-f namefile] [-m magicfiles] file...\n"
+# define USAGE "Usage: %s [-vbcz] [-f namefile] [-m magicfiles] file...\n"
#endif
#ifndef MAGIC
@@ -66,6 +66,7 @@ static char *moduleid = "$OpenBSD: file.c,v 1.8 2002/02/16 21:27:46 millert Exp
int /* Global command-line options */
debug = 0, /* debugging */
+ bflag = 0, /* Don't print filename */
lflag = 0, /* follow Symlinks (BSD only) */
zflag = 0; /* follow (uncompress) compressed files */
@@ -100,12 +101,15 @@ char *argv[];
if (!(magicfile = getenv("MAGIC")))
magicfile = MAGIC;
- while ((c = getopt(argc, argv, "vcdf:Lm:z")) != -1)
+ while ((c = getopt(argc, argv, "bvcdf:Lm:z")) != -1)
switch (c) {
case 'v':
(void) printf("%s-%d.%d\n", __progname,
FILE_VERSION_MAJOR, patchlevel);
return 1;
+ case 'b':
+ ++bflag;
+ break;
case 'c':
++check;
break;
@@ -297,7 +301,7 @@ int wid;
inname = stdname;
}
- if (wid > 0)
+ if (wid > 0 && !bflag)
(void) printf("%s:%*s ", inname,
(int) (wid - strlen(inname)), "");