file(1) doesn't recognize scripts correctly

From: Jens Rehsack <rehsack_at_liwing.de>
Date: Thu, 05 Jun 2003 11:52:32 +0200
Hi David, hi list,

you got this mail, because you maintain src/contrib/file/. If you're not
responsible, please let me know and I will find someone else to bother
with this :-)

I was playing around with file(1) to find a solution for detecting file
content correctly. I've detected, that the pattern in
src/contrib/file/Magfiles/commands which are useful detecting unknow
scripts correctly (lines 44-52), prevents file from detecting eg. perl
or scripts correctly.

Sample:
$ file -b /var/www/data/trevor/flexpage/tools/fpcombinelib
a /usr/local/bin/php -Cqe script text executable
$ file -b /var/www/data/trevor/flexpage/tools/getPage.pl
a /usr/bin/perl script text executable

I created a patch which may only a workaround until a script language is
added which first letters are bigger than 'various'. Maybe a better
solution would be renaming all scripts to 'script.shell', 'script.php',
'script.perl', ... 'script.various' or concatanation order is created.

Last one may be the best solution. Please let me know what you think.

Sample after patch:
$ file -b /var/www/data/trevor/flexpage/tools/getPage.pl
perl script text executable
$ file -b /var/www/data/trevor/flexpage/tools/fpcombinelib
PHP script text executable

Regards,
Jens

diff -uNr Magdir.old/commands Magdir/commands
--- Magdir.old/commands	Thu Jun  5 09:43:50 2003
+++ Magdir/commands	Thu Jun  5 09:46:15 2003
_at__at_ -40,17 +40,6 _at__at_
 0	string		#!\ /usr/bin/env	a
 >16	string		>\0			%s script text executable
 
-
-# generic shell magic
-0	string		#!\ /			a
->3	string		>\0			%s script text executable
-0	string		#!\	/		a
->3	string		>\0			%s script text executable
-0	string		#!/			a
->2	string		>\0			%s script text executable
-0	string		#!\ 			script text executable
->3	string		>\0			for %s
-
 # PHP scripts
 # Ulf Harnhammar <ulfh_at_update.uu.se>
 0	string/c	=<?php			PHP script text
diff -uNr Magdir.old/varied.script Magdir/varied.script
--- Magdir.old/varied.script	Thu Jan  1 00:00:00 1970
+++ Magdir/varied.script	Thu Jun  5 09:46:15 2003
_at__at_ -0,0 +1,11 _at__at_
+# generic shell magic
+0	string		#!\ /			a
+>3	string		>\0			%s script text executable
+0	string		#!\	/		a
+>3	string		>\0			%s script text executable
+0	string		#!/			a
+>2	string		>\0			%s script text executable
+0	string		#!\ 			script text executable
+>3	string		>\0			for %s
+
+
Received on Thu Jun 05 2003 - 00:52:36 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:10 UTC