summaryrefslogtreecommitdiff
path: root/mcon/U/startperl.U
blob: 431c1a9e623ad0120e790829f9b55defa8922222 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
?RCS: $Id: startperl.U 167 2013-05-08 17:58:00Z rmanfredi $
?RCS:
?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi
?RCS: 
?RCS: You may redistribute only under the terms of the Artistic License,
?RCS: as specified in the README file that comes with the distribution.
?RCS: You may reuse parts of this distribution only within the terms of
?RCS: that same Artistic License; a copy of which may be found at the root
?RCS: of the source tree for dist 4.0.
?RCS:
?RCS: $Log: startperl.U,v $
?RCS: Revision 3.0.1.1  1997/02/28  16:25:06  ram
?RCS: patch61: warn them if the #! line is too long for their OS
?RCS:
?RCS: Revision 3.0  1993/08/18  12:09:50  ram
?RCS: Baseline for dist 3.0 netwide release.
?RCS:
?MAKE:startperl: cat rm sharpbang perlpath d_portable Myread
?MAKE:	-pick add $@ %<
?S:startperl:
?S:	This variable contains the string to put on the front of a perl
?S:	script to make sure (hopefully) that it runs with perl and not some
?S:	shell. Of course, that leading line must be followed by the classical
?S:	perl idiom:
?S:		eval 'exec perl -S $0 ${1+"$@"}'
?S:			if $running_under_some_shell;
?S:	to guarantee perl startup should the shell execute the script. Note
?S:	that this magic incantation is not understood by csh.
?S:.
?C:STARTPERL:
?C:	This symbol is the string that should be put on the front of a
?C:	perl script to make sure (hopefully) that it runs with perl and
?C:	not under some shell. That line should be followed by the classical
?C:	invocation magic:
?C:		eval 'exec perl -S $0 ${1+"$@"}'
?C:			if $running_under_some_shell;
?C:	to guarantee perl startup should the shell execute the script at first.
?C:.
?H:#define STARTPERL "$startperl"
?H:.
?T:pdflt
?F:!xtry
: figure out how to guarantee perl startup
case "$sharpbang" in
*!)
?X:
?X: Make sure the #!$perlpath magic incantation indeed works on this
?X: system... It might not if the length of the #! hook is greater
?X: than some hardwired kernel limit. -- RAM, 15/03/96
?X:
	$cat >xtry <<EOP
#!$perlpath
system("exit 0");
EOP
	chmod a+x xtry
	if ./xtry >/dev/null 2>&1; then
		$cat <<EOH

I can use the #! construct to start perl on your system. This will make
startup of perl scripts faster, but may cause problems if you want to share
those scripts and perl is not in a standard place (/usr/bin/perl) on all your
platforms. The alternative is to force a shell by starting the script with a
single ':' character.

EOH
		pdflt=y
	else
		$cat <<EOH

I could use the #! construct to start perl on your system, but using
    #!$perlpath
would be too long for your kernel to grok. Indeed, most systems do
limit the size of the leading #! string to 32 characters.

EOH
		pdflt=n
	fi
	$rm -f xtry
	case "$startperl" in
	*!*) dflt=y;;
	'') case "$d_portable" in
		"$define") dflt=n;;
		*) dflt=$pdflt;;
		esac;;
	*) dflt=n;;
	esac
	rp='Shall I use #! to start up perl?'
	. ./myread
	case "$ans" in
	y*|Y*) startperl="#!$perlpath";;
	*) startperl=": # use perl";;
	esac;;
*) startperl=": # use perl";;
esac