Permalink
Browse files

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>
  • Loading branch information...
0xffea authored and gwr committed Apr 11, 2014
1 parent 9c720e3 commit 6e987ca0b653b6724551e3e999d35f05512a5a6a
Showing with 32 additions and 16 deletions.
  1. +14 −7 usr/src/cmd/file/file.c
  2. +18 −9 usr/src/man/man1/file.1
@@ -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,14 +219,18 @@ 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':
add_to_mlist(optarg, !dflg);
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);
}
@@ -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
@@ -103,6 +103,15 @@ be determined.
.sp
.LP
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

0 comments on commit 6e987ca

Please sign in to comment.