logo       

Re: patch to allow extra perl args on #! lines: msg#00012

db.rddtool.munin.general

Subject: Re: patch to allow extra perl args on #! lines

On Tuesday, 2006-12-05 at 23:19:38 +0100, Nicolai Langfeldt wrote:

> $ sed '1 s~^\(#!.*perl.*\)$~\1\nuse lib "/custom/perl/lib";~' *.pl
> #!/usr/bin/perl -Tw
> use lib "/custom/perl/lib";
> # foo!

> print "bar\n";

Gotcha!

\n in sed is non-portable. This is from Solaris 8:

sed '1 s~^\(#!.*perl.*\)$~\1\nuse lib "/custom/perl/lib";~' /tmp/bar.pl
#!/usr/bin/perl -Twnuse lib "/custom/perl/lib";
# foo!

print "bar\n";

Why don't you use perl?

perl -p -i.bak -e 's~^(#!.*perl.*)$~\1\nuse lib "/custom/perl/lib";~ if $. ==
1' *.pl

Lupe
--
| You know we're sitting on four million pounds of fuel, one nuclear |
| weapon and a thing that has 270,000 moving parts built by the lowest |
| bidder. Makes you feel good, doesn't it? |
| Rockhound in "Armageddon", 1998, about the Space Shuttle |

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise