View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0000397||file||General||public||2022-10-20 09:55||2022-10-27 19:20|
|Fixed in Version||5.44|
|Summary||0000397: Regression in mode -f- (stdin)|
|Description||Upto file-5.42 an application may popen("file -bnf-"), feed it with filenames and get results immediately.|
(echo /lib/libc.so.7; sleep 3600) | file -bnf -
Such command prints result immediately with file-5.42.
file-5.43 does not print result immediately.
It was broken with following commit:
Rollback of that commit fixes the regression.
|Steps To Reproduce||See above.|
|Additional Information||The problem is serious as it breaks application that continuously feed "file -bnf-" with filenames and expect results at once, before EOF.|
||Added -I flag to address this.|
Thank you very much for prompt response. Sadly, new flag still does not restore breakage of existing applications that rely on previous behaviour that existed for long time; applications would need to be modified and its is not always possible.
Please consider adding new flag for new behaviour instead, so that "file -bnf-" would behave as before.
I am guessing that there are very few applications that depend on this behavior (which was not guaranteed anyway). I think that it is better to have consistent output between:
cat foo | file -f -
file -f foo
as opposed to having them be different by default. If you want immediate results and inconsistent output, you should be explicit about it. Now that I think about it, there is nothing special about -f - vs -f /dev/stdin, so I better fix it to be also consistent.
Such applications do exist, nevertheless. Now they cannot just run "file" with same set of flags for any operating system, because different systems will have different "file" versions with different default behaviour for considerable time.
# echo my.cnf | file -bnIf -
file: invalid option -- I
Usage: file [-bcCdEhikLlNnprsSvzZ0] [--apple] [--extension] [--mime-encoding]
[--mime-type] [-e <testname>] [-F <separator>] [-f <namefile>]
[-m <magicfiles>] [-P <parameter=value>] [--exclude-quiet]
file -C [-m <magicfiles>]
||I am not very sympathetic of such apps. They could easily be converted to use libmagic. Running commands needlessly causes security issues (for example filenames with \n in them will not be processed correctly.|
From the manual page:
Force stdout to be flushed after checking each file. This is
only useful if checking a list of files. It is intended to be
used by programs that want filetype output from a pipe.
For me, it means that behaviour was "guaranteed".
||Here is a good point! I just used -n to restore the previous behavior and removed -I.|
||Thank you very much for this change. It really fixes compatibility. This PR can be closed now.|
|2022-10-20 09:55||dadv||New Issue|
|2022-10-20 09:55||dadv||Tag Attached: regression|
|2022-10-23 14:23||christos||Assigned To||=> christos|
|2022-10-23 14:23||christos||Status||new => assigned|
|2022-10-23 14:23||christos||Status||assigned => resolved|
|2022-10-23 14:23||christos||Resolution||open => fixed|
|2022-10-23 14:23||christos||Fixed in Version||=> 5.44|
|2022-10-23 14:23||christos||Note Added: 0003845|
|2022-10-23 20:18||dadv||Status||resolved => feedback|
|2022-10-23 20:18||dadv||Resolution||fixed => reopened|
|2022-10-23 20:18||dadv||Note Added: 0003846|
|2022-10-24 20:19||christos||Note Added: 0003848|
|2022-10-25 02:07||dadv||Note Added: 0003849|
|2022-10-25 02:07||dadv||Status||feedback => assigned|
|2022-10-25 22:25||christos||Note Added: 0003850|
|2022-10-26 08:21||dadv||Note Added: 0003851|
|2022-10-26 16:57||christos||Note Added: 0003852|
|2022-10-27 01:59||dadv||Note Added: 0003854|
|2022-10-27 19:20||christos||Status||assigned => resolved|