summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorDavid Höppner <0xffea@gmail.com>2014-04-11 16:58:14 +0000
committerGordon Ross <gwr@nexenta.com>2014-04-26 11:31:09 -0400
commit6e987ca0b653b6724551e3e999d35f05512a5a6a (patch)
treec305c2f4b281a0be825e61659c2991f6cd6bb691 /usr/src
parent9c720e3bfb657054035cb780c4d222291b7d4917 (diff)
downloadillumos-joyent-6e987ca0b653b6724551e3e999d35f05512a5a6a.tar.gz
4732 /usr/bin/file should provide -b option for compatiblity with GNU/BSD file
Reviewed by: Andy Stormont <andyjstormont@gmail.com> Reviewed by: Serghei Samsi <sscdvp@gmail.com> Reviewed by: Alexander Pyhalov <alp@rsu.ru> Reviewed by: Garrett D'Amore <garrett@damore.org> Approved by: Gordon Ross <gwr@nexenta.com>
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/cmd/file/file.c21
-rw-r--r--usr/src/man/man1/file.127
2 files changed, 32 insertions, 16 deletions
diff --git a/usr/src/cmd/file/file.c b/usr/src/cmd/file/file.c
index 70cb43c005..6c7989d735 100644
--- a/usr/src/cmd/file/file.c
+++ b/usr/src/cmd/file/file.c
@@ -205,6 +205,7 @@ main(int argc, char **argv)
char *p;
int ch;
FILE *fl;
+ int bflg = 0;
int cflg = 0;
int eflg = 0;
int fflg = 0;
@@ -218,7 +219,7 @@ main(int argc, char **argv)
#endif
(void) textdomain(TEXT_DOMAIN);
- while ((ch = getopt(argc, argv, "M:cdf:him:")) != EOF) {
+ while ((ch = getopt(argc, argv, "M:bcdf:him:")) != EOF) {
switch (ch) {
case 'M':
@@ -226,6 +227,10 @@ main(int argc, char **argv)
M_flg++;
break;
+ case 'b':
+ bflg++;
+ break;
+
case 'c':
cflg++;
break;
@@ -288,7 +293,7 @@ main(int argc, char **argv)
if (iflg && (dflg || mflg || M_flg)) {
usage();
}
- if (iflg && cflg) {
+ if ((iflg && cflg) || (cflg && bflg)) {
usage();
}
@@ -409,7 +414,9 @@ main(int argc, char **argv)
p[l - 1] = '\0';
} else
p = argv[optind];
- prf(p); /* print "file_name:<tab>" */
+
+ if (!bflg)
+ prf(p); /* print "file_name:<tab>" */
if (type(p))
tret = 1;
@@ -1645,10 +1652,10 @@ static void
usage(void)
{
(void) fprintf(stderr, gettext(
- "usage: file [-dh] [-M mfile] [-m mfile] [-f ffile] file ...\n"
- " file [-dh] [-M mfile] [-m mfile] -f ffile\n"
- " file -i [-h] [-f ffile] file ...\n"
- " file -i [-h] -f ffile\n"
+ "usage: file [-bdh] [-M mfile] [-m mfile] [-f ffile] file ...\n"
+ " file [-bdh] [-M mfile] [-m mfile] -f ffile\n"
+ " file -i [-bh] [-f ffile] file ...\n"
+ " file -i [-bh] -f ffile\n"
" file -c [-d] [-M mfile] [-m mfile]\n"));
exit(2);
}
diff --git a/usr/src/man/man1/file.1 b/usr/src/man/man1/file.1
index 723d1b6063..139f597f53 100644
--- a/usr/src/man/man1/file.1
+++ b/usr/src/man/man1/file.1
@@ -7,28 +7,28 @@
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
-.TH FILE 1 "Sep 10, 2013"
+.TH FILE 1 "Apr 11, 2014"
.SH NAME
file \- determine file type
.SH SYNOPSIS
.LP
.nf
-\fB/usr/bin/file\fR [\fB-dh\fR] [\fB-m\fR \fImfile\fR] [\fB-M\fR \fIMfile\fR] [\fB-f\fR \fIffile\fR] \fIfile\fR...
+\fB/usr/bin/file\fR [\fB-bdh\fR] [\fB-m\fR \fImfile\fR] [\fB-M\fR \fIMfile\fR] [\fB-f\fR \fIffile\fR] \fIfile\fR...
.fi
.LP
.nf
-\fB/usr/bin/file\fR [\fB-dh\fR] [\fB-m\fR \fImfile\fR] [\fB-M\fR \fIMfile\fR] \fB-f\fR \fIffile\fR
+\fB/usr/bin/file\fR [\fB-bdh\fR] [\fB-m\fR \fImfile\fR] [\fB-M\fR \fIMfile\fR] \fB-f\fR \fIffile\fR
.fi
.LP
.nf
-\fB/usr/bin/file\fR \fB-i\fR [\fB-h\fR] [\fB-f\fR \fIffile\fR] \fIfile\fR...
+\fB/usr/bin/file\fR \fB-i\fR [\fB-bh\fR] [\fB-f\fR \fIffile\fR] \fIfile\fR...
.fi
.LP
.nf
-\fB/usr/bin/file\fR \fB-i\fR [\fB-h\fR] \fB-f\fR \fIffile\fR
+\fB/usr/bin/file\fR \fB-i\fR [\fB-bh\fR] \fB-f\fR \fIffile\fR
.fi
.LP
@@ -38,22 +38,22 @@ file \- determine file type
.LP
.nf
-\fB/usr/xpg4/bin/file\fR [\fB-dh\fR] [\fB-m\fR \fImfile\fR] [\fB-M\fR \fIMfile\fR] [\fB-f\fR \fIffile\fR] \fIfile\fR...
+\fB/usr/xpg4/bin/file\fR [\fB-bdh\fR] [\fB-m\fR \fImfile\fR] [\fB-M\fR \fIMfile\fR] [\fB-f\fR \fIffile\fR] \fIfile\fR...
.fi
.LP
.nf
-\fB/usr/xpg4/bin/file\fR [\fB-dh\fR] [\fB-m\fR \fImfile\fR] [\fB-M\fR \fIMfile\fR] \fB-f\fR \fIffile\fR
+\fB/usr/xpg4/bin/file\fR [\fB-bdh\fR] [\fB-m\fR \fImfile\fR] [\fB-M\fR \fIMfile\fR] \fB-f\fR \fIffile\fR
.fi
.LP
.nf
-\fB/usr/xpg4/bin/file\fR \fB-i\fR [\fB-h\fR] [\fB-f\fR \fIffile\fR] \fIfile\fR...
+\fB/usr/xpg4/bin/file\fR \fB-i\fR [\fB-bh\fR] [\fB-f\fR \fIffile\fR] \fIfile\fR...
.fi
.LP
.nf
-\fB/usr/xpg4/bin/file\fR \fB-i\fR [\fB-h\fR] \fB-f\fR \fIffile\fR
+\fB/usr/xpg4/bin/file\fR \fB-i\fR [\fB-bh\fR] \fB-f\fR \fIffile\fR
.fi
.LP
@@ -106,6 +106,15 @@ The following options are supported:
.sp
.ne 2
.na
+\fB\fB-b\fR\fR
+.ad
+.RS 12n
+Be brief, do not print leading filename.
+.RE
+
+.sp
+.ne 2
+.na
\fB\fB-c\fR\fR
.ad
.RS 12n