From: Alexey Tourbin <at@altlinux.ru> To: ALT Devel discussion list <devel@lists.altlinux.org> Subject: Re: [devel] [JT] GroupUserFolder-3.2-alt1.1 lazarus-0.9.22-alt1 Date: Wed, 12 Sep 2007 01:39:30 +0400 Message-ID: <20070911213930.GV6051@solemn.turbinal> (raw) In-Reply-To: <20070911200848.GC19827@hell.fortress> [-- Attachment #1: Type: text/plain, Size: 2003 bytes --] On Wed, Sep 12, 2007 at 12:08:48AM +0400, Alexey I. Froloff wrote: > * Alexey Tourbin <at@> [070911 23:46]: > > #!/bin/sh > > exec perl -w -x $0 ${1+"$@"} # -*- mode: perl; perl-indent-level: 2; -*- > > #!perl -w > Я где-то видел офигенно портабельный перловый шебанг, который > работает на всех-всех-всех платформах с любым sh и perl. > Занимает он 12 строк. Этот вроде сделал. Всякую фигню maintainer'ы пакуют а мне страдай! commit 05cd09ba0f8559f835ac770946d673fb4ad887c0 Author: Alexey Tourbin <at@altlinux> Date: Wed Sep 12 01:32:35 2007 +0400 perl.req: implemented support for "perl -x" re-exec hack (fixes cvs2cl.pl) $ 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 = shift; open my $fh, $fname or die "$0: $fname: $!\n"; - my $shebang = <$fh>; - chomp $shebang; + local $_ = <$fh>; my @argv; - if ($shebang =~ s/^#!\s*\S*perl\S*\s*// && $shebang) { - local $_ = $shebang; + if (s/^#!\s*\S*perl\S*//) { foreach my $arg (split) { last if $arg =~ /^#/; 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 = 1; + } + elsif ($maybe_x and s/^#!\s*\S*perl\S*//) { + push @argv, "-x"; + foreach my $arg (split) { + last if $arg =~ /^#/; + next if $arg eq "--"; + push @argv, $arg; + } + last; + } + } + } return @argv; } [-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
next prev parent reply other threads:[~2007-09-11 21:39 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2007-09-11 19:45 [devel] " Alexey Tourbin 2007-09-11 20:08 ` [devel] [JT] " Alexey I. Froloff 2007-09-11 21:39 ` Alexey Tourbin [this message] 2007-09-12 5:29 ` Алексей Шенцев 2007-09-12 8:58 ` [devel] [JT] GroupUserFolder-3.2-alt1.1 lazarus-0.9.22-alt1' Alexey Tourbin
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20070911213930.GV6051@solemn.turbinal \ --to=at@altlinux.ru \ --cc=devel@lists.altlinux.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
ALT Linux Team development discussions This inbox may be cloned and mirrored by anyone: git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \ devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru public-inbox-index devel Example config snippet for mirrors. Newsgroup available over NNTP: nntp://lore.altlinux.org/org.altlinux.lists.devel AGPL code for this site: git clone https://public-inbox.org/public-inbox.git