You are here: Foswiki>Tasks Web>Item9765 (01 Nov 2012, GeorgeClark)Edit Attach

Item9765: Improve the rewriteshebang.pl script and rename it.

pencil
Priority: Normal
Current State: Closed
Released In: 1.1.2
Target Release: patch
Applies To: Extension
Component:
Branches:
Reported By: IngoKappler
Waiting For:
Last Change By: GeorgeClark
At least the SyntaxHighlightingPlugin has an issue here.

-- IngoKappler - 29 Sep 2010

rewriteshbang.pl only changed files without suffix, hence running it missed quite some files expecially in the tools directory. I am going to commit a new regex for file matching which probably will be:
# Grep relevant files to process while only including .pl, .cgi or .?cgi
# Keep .bak and this script excluded.
# ^\w+$ matches only alphanumeric characters between beginning and end
# ^\w+\.pl$ alphanumeric, a dot and pl between beginning and end
# ^\w+\..?cgi$ alphanumeric, a dot, 0 or 1 single char. and cgi between...

foreach my $file (grep { -f && /(^\w+$|^(?!rewriteshbang)\w+\.pl$|^\w+\..?cgi$)/ } readdir D)

-- IngoKappler - 30 Sep 2010

As of now it turned out that I ended up with some kind of refactoring, so the script will now do the following:

[foswiki@x tools]$ perl ../tools/rewriteshbang.pl

Change the "shebang" lines of all perl scripts found either in the current
directory or as configured in @directories. Default is to change:
../tools and ../bin directories. You will be asked to confirm accordingly.

"shebang" lines tell the shell what interpreter to use for running scripts.
By default the Foswiki bin scripts are set to use the "/usr/bin/perl"
interpreter, which is where perl lives on most UNIX-like platforms. On some
platforms you will need to change this line to run a different interpreter
e.g. "D:\indigoperl\bin\perl" or "/usr/bin/speedy"

This script will change the "shebang" lines of all scripts found in the
confirmed directories except for itself.

Note: the path to the interpreter *must not* contain any spaces.
Enter path to interpreter [hit enter to choose 'perl']: /opt/perl_local/perl5/perlbrew/bin/perl
Enter path to interpreter [hit enter to choose '/opt/perl_local/perl5/perlbrew/bin/perl']:

"No" will only change "shebang" lines of scripts found in the directory where the script is run from.
Are you sure you want to change scripts in the 2 directories:
../tools
../bin
(y/n)?: y

Modified files:
'/opt/apache/www/foswiki.1.0.10/tools/geturl.pl'
'/opt/apache/www/foswiki.1.0.10/tools/extender.pl'
'/opt/apache/www/foswiki.1.0.10/tools/EasyTimeline.pl'
'/opt/apache/www/foswiki.1.0.10/tools/minifycss'
'/opt/apache/www/foswiki.1.0.10/tools/tick_foswiki.pl'
'/opt/apache/www/foswiki.1.0.10/tools/tml2html.pl'
'/opt/apache/www/foswiki.1.0.10/tools/upgrade_emails.pl'
'/opt/apache/www/foswiki.1.0.10/tools/mailnotify'
'/opt/apache/www/foswiki.1.0.10/tools/EasyTimelinePlugin_convert.pl'
'/opt/apache/www/foswiki.1.0.10/tools/html2tml.pl'
'/opt/apache/www/foswiki.1.0.10/tools/mod_perl_startup.pl'
'/opt/apache/www/foswiki.1.0.10/tools/SyntaxHighlightingPlugin_covert.pl'
'/opt/apache/www/foswiki.1.0.10/tools/minifyjs'
'/opt/apache/www/foswiki.1.0.10/tools/actionnotify'
12 of 14 files changed

Modified files:
'/opt/apache/www/foswiki.1.0.10/bin/resetpasswd'
'/opt/apache/www/foswiki.1.0.10/bin/changes'
'/opt/apache/www/foswiki.1.0.10/bin/compare'
'/opt/apache/www/foswiki.1.0.10/bin/uploadexcel'
'/opt/apache/www/foswiki.1.0.10/bin/rest'
'/opt/apache/www/foswiki.1.0.10/bin/view'
'/opt/apache/www/foswiki.1.0.10/bin/viewfile'
'/opt/apache/www/foswiki.1.0.10/bin/rename'
'/opt/apache/www/foswiki.1.0.10/bin/table2excel'
'/opt/apache/www/foswiki.1.0.10/bin/search'
'/opt/apache/www/foswiki.1.0.10/bin/genpdf'
'/opt/apache/www/foswiki.1.0.10/bin/call.cgi'
'/opt/apache/www/foswiki.1.0.10/bin/excel2topics'
'/opt/apache/www/foswiki.1.0.10/bin/preview'
'/opt/apache/www/foswiki.1.0.10/bin/register'
'/opt/apache/www/foswiki.1.0.10/bin/viewauth'
'/opt/apache/www/foswiki.1.0.10/bin/rdiffauth'
'/opt/apache/www/foswiki.1.0.10/bin/foswiki.fcgi'
'/opt/apache/www/foswiki.1.0.10/bin/rdiff'
'/opt/apache/www/foswiki.1.0.10/bin/logon'
'/opt/apache/www/foswiki.1.0.10/bin/configure'
'/opt/apache/www/foswiki.1.0.10/bin/statistics'
'/opt/apache/www/foswiki.1.0.10/bin/oops'
'/opt/apache/www/foswiki.1.0.10/bin/save'
'/opt/apache/www/foswiki.1.0.10/bin/login'
'/opt/apache/www/foswiki.1.0.10/bin/edit'
'/opt/apache/www/foswiki.1.0.10/bin/topics2excel'
'/opt/apache/www/foswiki.1.0.10/bin/attach'
'/opt/apache/www/foswiki.1.0.10/bin/upload'
'/opt/apache/www/foswiki.1.0.10/bin/kinosearch'
'/opt/apache/www/foswiki.1.0.10/bin/manage'
31 of 31 files changed

[foswiki@x tools]$

-- IngoKappler - 06 Oct 2010

Please rename the script too while you're at it smile rewriteshebang.pl makes more sense.

But I know, it will break stuff... blah blah blah...

-- OlivierRaginel - 06 Oct 2010

On Windows via ActivePerl:

Running Perl 5.012001

Change the "shebang" lines of all perl scripts found either in the current
directory or as configured in @directories. Default is to change:
../tools and ../bin directories. You will be asked to confirm accordingly.

"shebang" lines tell the shell what interpreter to use for running scripts.
By default the Foswiki bin scripts are set to use the "/usr/bin/perl"
interpreter, which is where perl lives on most UNIX-like platforms. On some
platforms you will need to change this line to run a different interpreter
e.g. "D:\indigoperl\bin\perl" or "/usr/bin/speedy"

This script will change the "shebang" lines of all scripts found in the
confirmed directories except for itself.

Note: the path to the interpreter *must not* contain any spaces.
Enter path to interpreter [hit enter to choose 'C:\Perl\bin\perl.exe']:

"No" will only change "shebang" lines of scripts found in the directory
where the script is run from. Are you sure you want to change scripts
in the 2 directories:
../tools
../bin
(y/n)?:

-- IngoKappler - 06 Oct 2010

Oh, I just read your comment about renaming. I will do so then. Actually I looked into it already but wasn't sure if maybe the intention was to use sh-bang. But I already found it confusing especially when searching foswiki.org, we'll find several entries for "shebang" but not the InstallationGuide which is only talking about rewriteshbang.pl. So I will also change the install guide accordingly, later on.

-- IngoKappler - 06 Oct 2010

Ingo, Just note that with 1.1, for Extensions, the new package installer should auto-fixup the shebang line of any bin script using the function Foswiki::Configure::Util::rewriteShbang() I didn't include the /tools/ scripts, so that probably ought to be a bug against Foswiki 1.1 Configure.

The installer assumes that whatever shbang line is used in the bin/configure script should be the correct. It extracts the shbang using =Foswiki::Configure::Util::getPerlLocation()

You might be able to reuse some of the Configure::Util code to reduce duplication.

-- GeorgeClark - 07 Oct 2010

Ok, interesting. Actually I wondered if an integration of the rewriteshebang script into configure would be a good move forward but considered it as a future enhancement, not yet as a bug, since I didn't know about the related new configure feature. smile

-- IngoKappler - 07 Oct 2010

Hey,

I yesterday took some time to further improve the script and hope I didn't too much by now. Actually I added command line options to feed the script with the path or alternative directories. While on it, I also added a switch for --noask so in theory it could be run e.g. from configure and then added a few other things and finally checked taint mode.

So, I am wondering if I went to far already or if you will agree that the set of features in the script is ok. It now also has a help and manual page... wink I had my fun, so I'd be happy it will also be useful. smile

I attached the whole thing, so you could have a look before I move it over to trunk and discussions will be raising only then.

-- IngoKappler - 18 Oct 2010

This item should have been in WaitingForRelease / Patch / 1.1.2

-- KennethLavrsen - 04 Nov 2010

Ok, sorry and thanks for hint.

-- IngoKappler - 04 Nov 2010
 

I Attachment Action Size Date Who Comment
rewriteshebang.pl.txttxt rewriteshebang.pl.txt manage 11 K 18 Oct 2010 - 16:16 IngoKappler For review.
Topic revision: r22 - 01 Nov 2012, GeorgeClark
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy