I discovered what is wrong with the perl files that dows not uses shebangs.
The perl file postprocess/rebase.pl is a valid executable script, but it does not uses shebang.
I took /usr/share/file/magic and there it is a mention for that kind of "magic" sign:
...
# commands: file(1) magic for various shells and interpreters
0 string : shell archive or script for antique kernel text
...
And tried to execute on command line this file. It is properly executed. So it is a valid script to run.
I have managed to grep the /usr/share/file/magic and the string "\ script" (with space) will manage to sort out just the executable ones.
So I changed my script to search for "\ script" using "grep" and "file" commands and no more file type (extensions) exclusion patterns.
It was tested here and attached on this email.
Francisco Kem Iti Saito
< #Use test as argument to find the files that are not executable for file command but have the execution bit set
< #The use of "\ script" was based on /usr/share/file/magic which is used by "file" command.
---
> # Set the exclusion pattern (e.g. not all perl files - pl - are detected as executable by file command because they use evaland there is no shebang)
>
> EXCLUSIONS="*.pl$|*.excludeme$"
12a14,15
>
> #Use test as argument to find the files that are not executable for file command but have the execution bit set
16c19
< find . -perm /u+x -type f -print0 |xargs -0 -n1 file|grep -v "\ script" |cut -d: -f1
---
> find . -perm /u+x -type f -print0 |xargs -0 -n1 file|grep -v executable|cut -d: -f1|grep -E -v ''$EXCLUSIONS''
22c25
< find . -perm /u+x -type f |xargs -n1 file |grep -v "\ script"|cut -d: -f1|xargs chmod -x
---
> find . -perm /u+x -type f |xargs -n1 file |grep -v executable|cut -d: -f1|grep -E -v ''$EXCLUSIONS''|xargs chmod -x
and the output of grep "\ script" on my Debian machine:
$ grep "\ script" /usr/share/file/magic
0 string : shell archive or script for antique kernel text
0 string/b #!\ /bin/sh Bourne shell script text executable
0 string/b #!\ /bin/csh C shell script text executable
0 string/b #!\ /bin/ksh Korn shell script text executable
0 string/b #!\ /bin/tcsh Tenex C shell script text executable
0 string/b #!\ /usr/local/tcsh Tenex C shell script text executable
0 string/b #!\ /usr/local/bin/tcsh Tenex C shell script text executable
0 string/b #!\ /bin/zsh Paul Falstad's zsh script text executable
0 string/b #!\ /usr/bin/zsh Paul Falstad's zsh script text executable
0 string/b #!\ /usr/local/bin/zsh Paul Falstad's zsh script text executable
0 string/b #!\ /usr/local/bin/ash Neil Brown's ash script text executable
0 string/b #!\ /usr/local/bin/ae Neil Brown's ae script text executable
0 string/b #!\ /bin/nawk new awk script text executable
0 string/b #!\ /usr/bin/nawk new awk script text executable
0 string/b #!\ /usr/local/bin/nawk new awk script text executable
0 string/b #!\ /bin/gawk GNU awk script text executable
0 string/b #!\ /usr/bin/gawk GNU awk script text executable
0 string/b #!\ /usr/local/bin/gawk GNU awk script text executable
0 string/b #!\ /bin/awk awk script text executable
0 string/b #!\ /usr/bin/awk awk script text executable
#0 regex BEGIN[[:space:]]*[{] awk script text
0 string/b #!\ /bin/rc Plan 9 rc shell script text executable
0 string/b #!\ /bin/bash Bourne-Again shell script text executable
0 string/b #!\ /usr/local/bin/bash Bourne-Again shell script text executable
>15 string >\0 %s script text executable
>16 string >\0 %s script text executable
# PHP scripts
0 string/c =<?php PHP script text
0 string =<?\n PHP script text
0 string =<?\r PHP script text
0 string/b #!\ /usr/local/bin/php PHP script text executable
0 string/b #!\ /usr/bin/php PHP script text executable
0 string Zend\x00 PHP script Zend Optimizer data
0 string WNGZWZSC Wingz compiled script
0 string/b #!\ /bin/perl perl script text executable
0 string eval\ "exec\ /bin/perl perl script text
0 string/b #!\ /usr/bin/perl perl script text executable
0 string eval\ "exec\ /usr/bin/perl perl script text
0 string/b #!\ /usr/local/bin/perl perl script text
0 string eval\ "exec\ /usr/local/bin/perl perl script text executable
0 string eval\ '(exit\ $?0)'\ &&\ eval\ 'exec perl script text
0 string """ a python script text executable
0 string/b #!\ /usr/bin/python python script text executable
# varied.script: file(1) magic for various interpreter scripts
>3 string >\0 %s script text executable
>3 string >\0 %s script text executable
>2 string >\0 %s script text executable
Em 24/03/2011 às 03:07 horas, "Tor Lillqvist" <tlillqvist@novell.com> escreveu:
> 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.
But if a Perl (or some other) script doesn't start with a #!, then it isn't executable. It can't be run as a command just by itself, the kernel (or Cygwin) doesn't know what interpreter to use. It has to be passed on the command-line as a parameter to the intended interpreter. So, such files should not have the executable bit set. Presumably they are run from the makefiles using an explicit Perl interpreter.
Now, another question is then whether we should add a suitable #! line to such scripts, and change the makefilery where necessary to just run them as commands? There probably are various complications here that won't show up on most systems/platforms, but will show up on some.
> Can you send me the git-hook pre-commit so I can try to modify it to make
> this tests automatically?
I am no git expert, but it should be in your git clone, surely?
--tml
_______________________________________________
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
lists.freedesktop.org/mailman/listinfo/libreoffice
Attachment:
find-non-executables-with-execution-bit.sh
Description: Binary data
Context
- Re: [Libreoffice] [PATCH] removing the executable mode from some source files · saito
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.