This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add the files from dist/meta to perl's repo
[metaconfig.git] / dist / U / startperl.U
CommitLineData
d8875586
MBT
1?RCS: $Id: startperl.U 1 2006-08-24 12:32:52Z rmanfredi $
2?RCS:
3?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi
4?RCS:
5?RCS: You may redistribute only under the terms of the Artistic Licence,
6?RCS: as specified in the README file that comes with the distribution.
7?RCS: You may reuse parts of this distribution only within the terms of
8?RCS: that same Artistic Licence; a copy of which may be found at the root
9?RCS: of the source tree for dist 4.0.
10?RCS:
11?RCS: $Log: startperl.U,v $
12?RCS: Revision 3.0.1.1 1997/02/28 16:25:06 ram
13?RCS: patch61: warn them if the #! line is too long for their OS
14?RCS:
15?RCS: Revision 3.0 1993/08/18 12:09:50 ram
16?RCS: Baseline for dist 3.0 netwide release.
17?RCS:
18?MAKE:startperl: cat rm sharpbang perlpath d_portable Myread
19?MAKE: -pick add $@ %<
20?S:startperl:
21?S: This variable contains the string to put on the front of a perl
22?S: script to make sure (hopefully) that it runs with perl and not some
23?S: shell. Of course, that leading line must be followed by the classical
24?S: perl idiom:
25?S: eval 'exec perl -S $0 ${1+"$@"}'
26?S: if $running_under_some_shell;
27?S: to guarantee perl startup should the shell execute the script. Note
28?S: that this magic incatation is not understood by csh.
29?S:.
30?C:STARTPERL:
31?C: This symbol is the string that should be put on the front of a
32?C: perl script to make sure (hopefully) that it runs with perl and
33?C: not under some shell. That line should be followed by the classical
34?C: invocation magic:
35?C: eval 'exec perl -S $0 ${1+"$@"}'
36?C: if $running_under_some_shell;
37?C: to guarantee perl startup should the shell execute the script at first.
38?C:.
39?H:#define STARTPERL "$startperl"
40?H:.
41?T:pdflt
42?F:!xtry
43: figure out how to guarantee perl startup
44case "$sharpbang" in
45*!)
46?X:
47?X: Make sure the #!$perlpath magic incantation indeed works on this
48?X: system... It might not if the length of the #! hook is greater
49?X: than some hardwired kernel limit. -- RAM, 15/03/96
50?X:
51 $cat >xtry <<EOP
52#!$perlpath
53system("exit 0");
54EOP
55 chmod a+x xtry
56 if ./xtry >/dev/null 2>&1; then
57 $cat <<EOH
58
59I can use the #! construct to start perl on your system. This will make
60startup of perl scripts faster, but may cause problems if you want to share
61those scripts and perl is not in a standard place (/usr/bin/perl) on all your
62platforms. The alternative is to force a shell by starting the script with a
63single ':' character.
64
65EOH
66 pdflt=y
67 else
68 $cat <<EOH
69
70I could use the #! construct to start perl on your system, but using
71 #!$perlpath
72would be too long for your kernel to grok. Indeed, most systems do
73limit the size of the leading #! string to 32 characters.
74
75EOH
76 pdflt=n
77 fi
78 $rm -f xtry
79 case "$startperl" in
80 *!*) dflt=y;;
81 '') case "$d_portable" in
82 "$define") dflt=n;;
83 *) dflt=$pdflt;;
84 esac;;
85 *) dflt=n;;
86 esac
87 rp='Shall I use #! to start up perl?'
88 . ./myread
89 case "$ans" in
90 y*|Y*) startperl="#!$perlpath";;
91 *) startperl=": # use perl";;
92 esac;;
93*) startperl=": # use perl";;
94esac
95