Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


Hi,

My script does not uses file extensions to check if a file is meant to be executable.
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)

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".

e.g.

        find . -perm /u+x -type f -print0 |xargs  -0 -n1 file|grep -v executable|cut -d: -f1|grep -E  -v ''$EXCLUSIONS''

this test is on  the portion "xargs -0 -n1 file" where file is the command and not a file.

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".

e.g.

The header for the file in postprocess rebase.pl does not use shebangs, it uses an old style for scripts that uses just comma:

head -n5 postprocess/rebase/rebase.pl
:
eval 'exec perl -wS $0 ${1+"$@"}'
    if 0;
#*************************************************************************
#

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".

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.


Francisco Saito


Em 23/03/2011 às 18:37 horas, "saito" <saito@4linux.com.br> escreveu:
Hi,

I have written an simple script based on find and file commands.

To use it, first it needs to set the exclusion pattern inside the script.
After that, you can run the script using "test" as argument to list the files that are not meant to be executable, example:

./find-non-executables-with-execution-bit.sh test

and use "execute" as argument to unset execution bit from all files that have execution bit but are not executable using "file command", example:

./find-non-executables-with-execution-bit.sh execute


Note: The exclusion pattern was needed because I have noted that some perl files are not using shebang, so the "file command"  cannot detect it as executable.


Can you send me the git-hook pre-commit so I can try to modify it to make this tests automatically?


Francisco Kem Iti Saito
4linux

Em 23/03/2011 às 12:34 horas, "Tor Lillqvist" <tlillqvist@novell.com> escreveu:
> OK. I will pass something like this (with more extensions) on all source 
> tree and will send patches after this:
>
> find -name "*.cxx" -o -name "*.hxx" -o -name "*.mk" -exec chmod -x '{}' \;

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.

(Also, much faster to use -print0 | xargs -0 chmod -x.)

--tml



Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.