Print this page
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>

@@ -203,10 +203,11 @@
 main(int argc, char **argv)
 {
         char    *p;
         int     ch;
         FILE    *fl;
+        int     bflg = 0;
         int     cflg = 0;
         int     eflg = 0;
         int     fflg = 0;
         char    *ap = NULL;
         int     pathlen;

@@ -216,18 +217,22 @@
 #if !defined(TEXT_DOMAIN)       /* Should be defined by cc -D */
 #define TEXT_DOMAIN "SYS_TEST"  /* Use this only if it weren't */
 #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;
 
                 case 'd':

@@ -286,11 +291,11 @@
         if (!cflg && !fflg && (eflg || optind == argc))
                 usage();
         if (iflg && (dflg || mflg || M_flg)) {
                 usage();
         }
-        if (iflg && cflg) {
+        if ((iflg && cflg) || (cflg && bflg)) {
                 usage();
         }
 
         if (!dflg && !mflg && !M_flg && !iflg) {
         /* no -d, -m, nor -M option; also -i option doesn't need magic  */

@@ -407,10 +412,12 @@
                         l = strlen(p);
                         if (l > 0)
                                 p[l - 1] = '\0';
                 } else
                         p = argv[optind];
+
+                if (!bflg)
                 prf(p);                         /* print "file_name:<tab>" */
 
                 if (type(p))
                         tret = 1;
         }

@@ -1643,14 +1650,14 @@
 
 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);
 }
 
 static uint32_t