4 ms·
I'm not sure to agree: if/as *nix systems do not use the extension to know the filetype, then `file`-like heuristics is the only other way to know the file natu
by wazari972 7y ago
I'm not sure to agree: if/as *nix systems do not use the extension to know the filetype, then `file`-like heuristics is the only other way to know the file nature, or do I miss someting?
- OskarS 7y agoPresumably OpenOffice could pass along a thing that says "please print this PostScript file" so that the printer software knows which type of file it is printing and doesn't have to guess with "file". OpenOffice knows what type of file it's outputting, after all. But your point arguably stands: if a user says "print file X", and you want different files printed using different logic (e.g. PDFs and PostScript files should be printed differently than text files), what other option is there other than using something like "file" to try and guess the file type? It would be very annoying for the user to have to specify each time from a massive list of possible optins.
- angrygoat 7y agoI think the issue here is the question that should be being asked is: "is this a postscript file?". `file` answers a different question, "what is the most likely type for this file?"
- TazeTSchnitzel 7y agoThere is no perfect heuristic here, because what if you, for example, want to print a plain text file that happens to be PostScript?
- zaarn 7y agoIn most cases, you can't print plaintext easily to a printer, it needs some format like PS, so your PS file would be converted into a PS script that outputs your PS file.
- TazeTSchnitzel 7y agoAre you sure? I am pretty sure a lot of printers support text directly, they use control codes for additional capabilities.
- zaarn 7y agoI'm fairly certain (minus Linefeed Printers of the old days) most modern printers are either Host-rendered (ie, the host renders text and tells the printer what to print) or use something like PCL, which even in the most plaintext mode, still requires some setup to describe and format the page. You can't just pipe a textfile into printer port and hope your printer spits out anything useful.
- jandrese 7y agoI remember the bad old days of only 10-20 years ago when it wasn't unheard of to send a document to the printer, then walk over to discover a zillion pages of plain text starting with %!PS-Adobe-3.0.
- efreak 7y agoI'm not sure if there's a different process involved here, but I vaguely remember that a recent network printer I had came with an ftp server that could be used to print, simply by dropping supported files into it. I never experimented with it, though, so I have no idea if it supported simple text files or required PostScript or some such.
- zaarn 7y agoIt most likely converted incoming files whenever necessary.
- atanasi 7y agoIn the case of printing, the context provides some information. In particular, Erlang JAM file seems unlikely to be printed.
- deleted 7y ago[deleted]
- pjc50 7y agoWell, the true UNIX philosophy is that everything is a text file ... .. but as one of the other comments says, programs which want specific interpretation should consider having their own heuristics, especially including "precedence". In the Excel example, it should be considering XLS and CSV first before trying other things.