App-ChangeShebang

 view release on metacpan or  search on metacpan

META.json  view on Meta::CPAN

{
   "abstract" : "change shebang lines for relocatable perl",
   "author" : [
      "Shoichi Kaji <skaji@cpan.org>"
   ],
   "dynamic_config" : 0,
   "generated_by" : "Dist::Zilla version 6.037, CPAN::Meta::Converter version 2.150013",
   "license" : [
      "perl_5"
   ],
   "meta-spec" : {
      "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",

lib/App/ChangeShebang.pm  view on Meta::CPAN

    rename $tmp_name, $file or die "rename $tmp_name, $file: $!\n";
}

1;
__END__

=encoding utf-8

=head1 NAME

App::ChangeShebang - change shebang lines for relocatable perl

=head1 SYNOPSIS

    > change-shebang /path/to/bin/script.pl

    > head -3 /path/to/bin/script.pl
    #!/bin/sh
    exec "$(dirname "$0")"/perl -x "$0" "$@"
    #!perl

lib/App/ChangeShebang.pm  view on Meta::CPAN

    #!/path/to/bin/perl

to

    #!/bin/sh
    exec "$(dirname "$0")"/perl -x "$0" "$@"
    #!perl

Why do we need this?

Let's say you build perl with relocatable enabled (C<-Duserelocatableinc>).
Then the shebang lines of executable scripts point at
the installation time perl binary path.

So if you move your perl directory to other places,
the shebang lines of executable scripts point at a wrong perl binary and
we cannot execute scripts. Oops!

A solution of that problem is to replace shebang lines by

    #!/bin/sh

lib/App/ChangeShebang.pm  view on Meta::CPAN

    #!perl

which means that scripts will be executed by the perl located in the same directory.

=head1 SEE ALSO

=over 4

=item L<Relocatable installations in perl5100delta.pod|https://metacpan.org/pod/distribution/perl/pod/perl5100delta.pod#Relocatable-installations>

=item L<https://github.com/shoichikaji/relocatable-perl>

=item L<https://github.com/shoichikaji/relocatable-perl-growthforecast>

=back

=head1 ARTIFACT ATTESTATIONS

GitHub Artifact Attestations are generated for release tarballs uploaded to
CPAN. If you care about provenance for the uploaded tarballs, see:

L<https://github.com/skaji/change-shebang/attestations>

script/change-shebang  view on Meta::CPAN

use experimental qw(lexical_subs signatures);

use App::ChangeShebang;

App::ChangeShebang->new->parse_options(@ARGV)->run;

__END__

=head1 NAME

change-shebang - change shebang lines for relocatable perl

=head1 SYNOPSIS

    > change-shebang [OPTIONS] FILES

    Options:
    --force, -f    skip dialogs that confirm the files to be changed
    --quiet, -q    don't output messages
    --help, -h     show this help
    --version, -v  show version



( run in 1.751 second using v1.01-cache-2.11-cpan-941387dca55 )