From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Wed, 12 Sep 2007 01:39:30 +0400 From: Alexey Tourbin To: ALT Devel discussion list Message-ID: <20070911213930.GV6051@solemn.turbinal> Mail-Followup-To: ALT Devel discussion list References: <20070911194500.GS6051@solemn.turbinal> <20070911200848.GC19827@hell.fortress> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="kZ4UZC+XGJOY4cNK" Content-Disposition: inline In-Reply-To: <20070911200848.GC19827@hell.fortress> Subject: Re: [devel] [JT] GroupUserFolder-3.2-alt1.1 lazarus-0.9.22-alt1 X-BeenThere: devel@lists.altlinux.org X-Mailman-Version: 2.1.9 Precedence: list Reply-To: ALT Linux Team development discussions List-Id: ALT Linux Team development discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Sep 2007 21:39:47 -0000 Archived-At: List-Archive: List-Post: --kZ4UZC+XGJOY4cNK Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Sep 12, 2007 at 12:08:48AM +0400, Alexey I. Froloff wrote: > * Alexey Tourbin [070911 23:46]: > > #!/bin/sh > > exec perl -w -x $0 ${1+"$@"} # -*- mode: perl; perl-indent-level: 2; -*- > > #!perl -w > =F1 =C7=C4=C5-=D4=CF =D7=C9=C4=C5=CC =CF=C6=C9=C7=C5=CE=CE=CF =D0=CF=D2= =D4=C1=C2=C5=CC=D8=CE=D9=CA =D0=C5=D2=CC=CF=D7=D9=CA =DB=C5=C2=C1=CE=C7, = =CB=CF=D4=CF=D2=D9=CA > =D2=C1=C2=CF=D4=C1=C5=D4 =CE=C1 =D7=D3=C5=C8-=D7=D3=C5=C8-=D7=D3=C5=C8 = =D0=CC=C1=D4=C6=CF=D2=CD=C1=C8 =D3 =CC=C0=C2=D9=CD sh =C9 perl. > =FA=C1=CE=C9=CD=C1=C5=D4 =CF=CE 12 =D3=D4=D2=CF=CB. =FC=D4=CF=D4 =D7=D2=CF=C4=C5 =D3=C4=C5=CC=C1=CC. =F7=D3=D1=CB=D5=C0 =C6=C9=C7=CE=C0 maintainer'=D9 =D0=C1=CB=D5=C0=D4 =C1 = =CD=CE=C5 =D3=D4=D2=C1=C4=C1=CA! commit 05cd09ba0f8559f835ac770946d673fb4ad887c0 Author: Alexey Tourbin Date: Wed Sep 12 01:32:35 2007 +0400 perl.req: implemented support for "perl -x" re-exec hack (fixes cvs2cl.= pl) =20 $ head -3 cvs2cl.pl #!/bin/sh exec perl -w -x $0 ${1+"$@"} # -*- mode: perl; perl-indent-level: 2; -*- #!perl -wT $ ./perl.req cvs2cl.pl /home/at/git.alt/rpm-build-perl/cvs2cl.pl syntax OK perl(File/Basename.pm) perl(Text/Wrap.pm) perl(Time/Local.pm) $ diff --git a/perl.req b/perl.req index 1285d2a..485e9c9 100755 --- a/perl.req +++ b/perl.req @@ -117,17 +117,35 @@ bad: sub shebang_options { my $fname =3D shift; open my $fh, $fname or die "$0: $fname: $!\n"; - my $shebang =3D <$fh>; - chomp $shebang; + local $_ =3D <$fh>; my @argv; - if ($shebang =3D~ s/^#!\s*\S*perl\S*\s*// && $shebang) { - local $_ =3D $shebang; + if (s/^#!\s*\S*perl\S*//) { foreach my $arg (split) { last if $arg =3D~ /^#/; next if $arg eq "--"; push @argv, $arg; } } + elsif (m[^#!\s*/bin/sh(\s|$)]) { + # check for "perl -x" re-exec hack + my $maybe_x; + while (<$fh>) { + # this is just a standard way to re-exec perl: + last if /^eval\s+'exec\s/; + if (/\bexec\s.*\bperl.*\s-x/) { + $maybe_x =3D 1; + } + elsif ($maybe_x and s/^#!\s*\S*perl\S*//) { + push @argv, "-x"; + foreach my $arg (split) { + last if $arg =3D~ /^#/; + next if $arg eq "--"; + push @argv, $arg; + } + last; + } + } + } return @argv; } =20 --kZ4UZC+XGJOY4cNK Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQFG5wsSfBKgtDjnu0YRAiCSAKCh/dLTGQxfmRsc12cj8w5IgNIdZQCgsq+j mb2qTpRLFhBTVWYPw1PCs5o= =ys5y -----END PGP SIGNATURE----- --kZ4UZC+XGJOY4cNK--