Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | #!/import/bw/tools/local/perl-5.8.0/bin/perl |
2 | ||
3 | eval 'exec /import/bw/tools/local/perl-5.8.0/bin/perl -S $0 ${1+"$@"}' | |
4 | if 0; # not running under some shell | |
5 | # | |
6 | # psh - Perl Shell | |
7 | # | |
8 | # Copyright (C) 1999-2003 Gregor N. Purdy. All rights reserved. | |
9 | # This script is free software. It may be copied or modified according | |
10 | # to the same terms as Perl itself. | |
11 | # | |
12 | ||
13 | package Psh; # still use a package so getopt etc. is not imported into | |
14 | # the shell namespace | |
15 | ||
16 | use Psh; | |
17 | require Psh::Locale; | |
18 | require Psh::Util; | |
19 | ||
20 | # | |
21 | # Parse the command line and deal with the options except -r, which is | |
22 | # handled in the MAIN program below. We do this part very early in this | |
23 | # file so that the results apply to all the setting up we do before the | |
24 | # MAIN program. | |
25 | # | |
26 | # option -i is ignored | |
27 | ||
28 | @Psh::origINC=@INC; # save it | |
29 | ||
30 | my %opt=(); | |
31 | ||
32 | if (@ARGV) { | |
33 | require Getopt::Std; | |
34 | Getopt::Std::getopts('Fiwrd:f:c:', \%opt); | |
35 | ||
36 | if ($opt{'r'}) { | |
37 | Psh::Util::print_error_i18n('no_r_flag'); | |
38 | exit 1; | |
39 | } | |
40 | ||
41 | # | |
42 | # -w is "warnings mode": | |
43 | # | |
44 | ||
45 | if ($opt{'w'}) { | |
46 | Psh::Util::print_out_i18n('simulate_perl_w'); | |
47 | $^W = 1; | |
48 | use strict; | |
49 | } | |
50 | ||
51 | # | |
52 | # -d is "debug mode": | |
53 | # | |
54 | ||
55 | if (exists($opt{'d'})) { $Psh::debugging = $opt{'d'}||'soie'; } | |
56 | else { $Psh::debugging = 0; } | |
57 | } | |
58 | ||
59 | Psh::Util::print_debug("Debugging!\n"); | |
60 | ||
61 | Psh::minimal_initialize; | |
62 | Psh::process_rc($opt{'f'}) unless $opt{'F'}; | |
63 | Psh::finish_initialize; | |
64 | ||
65 | # TODO: Is this implementation equivalent to sh's ? | |
66 | if($opt{'c'}) { | |
67 | Psh::evl($opt{'c'}); | |
68 | exit 0; | |
69 | } | |
70 | ||
71 | if (@ARGV) { | |
72 | Psh::process_args; | |
73 | } else { | |
74 | Psh::initialize_interactive_mode; | |
75 | while (1) { | |
76 | eval { Psh::main_loop; }; | |
77 | Psh::handle_message($@,'main_loop'); | |
78 | } | |
79 | } | |
80 | ||
81 | exit 0; |