Use the -n flag to produce immediate results and kill the short-lived -I.

(cherry picked from commit 425f9897f0ed791a6c216c24375bd9b3a42330a2)
This commit is contained in:
Christos Zoulas 2022-10-26 16:56:14 +00:00 committed by Xin LI
parent d5e82a1bb0
commit 5d5531f83b
3 changed files with 11 additions and 21 deletions

View File

@ -1,5 +1,5 @@
.\" $File: file.man,v 1.145 2022/10/23 14:22:53 christos Exp $
.Dd October 23, 2022
.\" $File: file.man,v 1.146 2022/10/26 16:56:14 christos Exp $
.Dd October 26, 2022
.Dt FILE __CSECTION__
.Os
.Sh NAME
@ -8,7 +8,7 @@
.Sh SYNOPSIS
.Nm
.Bk -words
.Op Fl bcdEhIiklLNnprsSvzZ0
.Op Fl bcdEhiklLNnprsSvzZ0
.Op Fl Fl apple
.Op Fl Fl exclude-quiet
.Op Fl Fl extension
@ -277,9 +277,6 @@ This option causes symlinks not to be followed
This is the default if the environment variable
.Dv POSIXLY_CORRECT
is not defined.
.It Fl I , Fl Fl immediate
When processing filenames from stdin, don't collect their names first in order
to compute their maximum namelength first, process them immediately.
.It Fl i , Fl Fl mime
Causes the
.Nm

View File

@ -85,8 +85,8 @@ int getopt_long(int, char * const *, const char *,
# define IFLNK_L ""
#endif
#define FILE_FLAGS "bcCdE" IFLNK_h "Iik" IFLNK_L "lNnprsSvzZ0"
#define OPTSTRING "bcCde:Ef:F:hiIklLm:nNpP:rsSvzZ0"
#define FILE_FLAGS "bcCdE" IFLNK_h "ik" IFLNK_L "lNnprsSvzZ0"
#define OPTSTRING "bcCde:Ef:F:hiklLm:nNpP:rsSvzZ0"
# define USAGE \
"Usage: %s [-" FILE_FLAGS "] [--apple] [--extension] [--mime-encoding]\n" \
@ -177,7 +177,7 @@ __dead
#endif
private void help(void);
private int unwrap(struct magic_set *, const char *, int);
private int unwrap(struct magic_set *, const char *);
private int process(struct magic_set *ms, const char *, int);
private struct magic_set *load(const char *, int);
private void setparam(const char *);
@ -198,7 +198,7 @@ main(int argc, char *argv[])
int sandbox = 1;
#endif
struct magic_set *magic = NULL;
int longindex, immed = 0;
int longindex;
const char *magicfile = NULL; /* where the magic is */
char *progname;
@ -278,7 +278,7 @@ main(int argc, char *argv[])
if ((magic = load(magicfile, flags)) == NULL)
return 1;
applyparam(magic);
e |= unwrap(magic, optarg, immed);
e |= unwrap(magic, optarg);
++didsomefiles;
break;
case 'F':
@ -287,9 +287,6 @@ main(int argc, char *argv[])
case 'i':
flags |= MAGIC_MIME;
break;
case 'I':
immed = 1;
break;
case 'k':
flags |= MAGIC_CONTINUE;
break;
@ -507,7 +504,7 @@ load(const char *magicfile, int flags)
* unwrap -- read a file of filenames, do each one.
*/
private int
unwrap(struct magic_set *ms, const char *fn, int immed)
unwrap(struct magic_set *ms, const char *fn)
{
FILE *f;
ssize_t len;
@ -531,7 +528,7 @@ unwrap(struct magic_set *ms, const char *fn, int immed)
if (line[len - 1] == '\n')
line[len - 1] = '\0';
cwid = file_mbswidth(ms, line);
if (immed) {
if (nobuffer) {
e |= process(ms, line, cwid);
free(line);
line = NULL;
@ -555,7 +552,7 @@ unwrap(struct magic_set *ms, const char *fn, int immed)
llen = 0;
}
if (!immed) {
if (!nobuffer) {
fimax = fi;
for (fi = 0; fi < fimax; fi++) {
e |= process(ms, flist[fi], wid);

View File

@ -45,10 +45,6 @@ OPT('F', "separator", 1, 0,
OPT('i', "mime", 0, 0,
" output MIME type strings (--mime-type and\n"
" --mime-encoding)\n")
OPT('I', "immediate", 0, 0,
" when reading filenames from stdin, process them\n"
" immediately, don't collect them to compute their\n"
" maximum name length\n")
OPT_LONGONLY("apple", 0, 0,
" output the Apple CREATOR/TYPE\n", OPT_APPLE)
OPT_LONGONLY("extension", 0, 0,