<body>
Hi,<br><br>My script does not uses file extensions to check if a file is meant to be executable.<br>It uses file extensions just for exclusion pattern. Mainly because I have found perl files that does not use shebangs (like postprocess/base/rebase.pl)<br><br>The script uses the Unix/Linux command "file" to check if the file is a executable. That is an automatic approach instead of checking and parsing the "head -n1FILE".<br><br>e.g.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; find . -perm /u+x -type f -print0 |xargs&nbsp; -0 -n1 file|grep -v executable|cut -d: -f1|grep -E&nbsp; -v ''$EXCLUSIONS''<br><br>this test is on&nbsp; the portion "xargs -0 -n1 file" where file is the command and not a file.<br><br>The exclusion pattern was needed because some files that are meant to be executables are not detected properly using the "file" command and greping "executable".<br><br>e.g.<br><br>The header for the file in postprocess rebase.pl does not use shebangs, it uses an old style for scripts that uses just comma:<br><br>head -n5 postprocess/rebase/rebase.pl<br>:<br>eval 'exec perl -wS $0 ${1+"$@"}'<br>&nbsp;&nbsp;&nbsp; if 0;<br>#*************************************************************************<br>#<br><br>And because of this I have made an exclusion pattern since this perl file is meant to be executable but it does not get detected as "executable" by the command "file".<br><br>If I change this perl scripts like rebase.pl to use shebangs and /usr/bin/env, this exclusion pattern probably will not be used. But It will be another script to find and change all of these perl files.<br><br><br>Francisco Saito
<br><br><br>Em 23/03/2011 ās 18:37 horas, "saito" &lt;saito@4linux.com.br&gt; escreveu:<blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class=""><span>
Hi,<br><br>I have written an simple script based on find and file commands.<br><br>To use it, first it needs to set the exclusion pattern inside the script.<br>After that, you can run the script using "test" as argument to list the files that are not meant to be executable, example:<br><br>./find-non-executables-with-execution-bit.sh test<br><br>and use "execute" as argument to unset execution bit from all files that have execution bit but are not executable using "file command", example:<br><br>./find-non-executables-with-execution-bit.sh execute<br><br><br>Note: The exclusion pattern was needed because I have noted that some perl files are not using shebang, so the "file command"&nbsp; cannot detect it as executable.<br><br><br>Can you send me the git-hook pre-commit so I can try to modify it to make this tests automatically?<br><br><br>Francisco Kem Iti Saito
<br>4linux<br><br>Em 23/03/2011 ās 12:34 horas, "Tor Lillqvist" &lt;<a href="mailto:tlillqvist@novell.com">tlillqvist@novell.com</a>&gt; escreveu:<blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><pre>&gt; OK. I will pass something like this (with more extensions) on all source <br>&gt; tree and will send patches after this:<br>&gt; <br>&gt;  find -name "*.cxx" -o -name "*.hxx" -o -name "*.mk" -exec chmod -x '{}' \;<br><br>Thanks, but it is simpler to just send the script, once you have a good set of file extensions to handle. We can still commit the resulting change giving you credit.<br><br>(Also, much faster to use -print0 | xargs -0 chmod -x.)<br><br>--tml<br><br><br></pre></blockquote>
</span></div></blockquote>
</body>