On Mon, Aug 12, 2013 at 02:51:52AM +0200, Adam Borowski wrote: > [...] > > On the other hand, detecting text files is hard. The best tool so far, > "file", makes so many errors it's useless for this purpose. One could use > location: like, declaring stuff in /etc/ and /usr/share/doc/ to be text > unless proven otherwise, but that's an incomplete hack. Only hashbangs can > be considered reliable, but scripts are not where most documentation goes.
Just a note: hashbangs can't really be considered reliable either -- consider tarball-in-sh/other-script files (waf is a good example). Then there's stuff like gambas-compiled executables which also ship with valid hashbangs, and #!/usr/bin/haserl stuff which can contain lua bytecode after the hashbang line. The only requirement for valid hashbangs, afaict, is that the first two bytes are #!, and everything up to the \x20 or \n is resolvable to a valid filename. > [...] -- Kind regards, Loong Jin
signature.asc
Description: Digital signature