File: psh

package info (click to toggle)
psh 1.8-4
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 812 kB
  • ctags: 520
  • sloc: perl: 7,327; makefile: 41; sh: 12
file content (78 lines) | stat: -rwxr-xr-x 1,517 bytes parent folder | download | duplicates (3)
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
#! /usr/bin/perl
#
# psh - Perl Shell
#
# Copyright (C) 1999-2003 Gregor N. Purdy. All rights reserved.
# This script is free software. It may be copied or modified according
# to the same terms as Perl itself.
#

package Psh; # still use a package so getopt etc. is not imported into
             # the shell namespace

use Psh;
require Psh::Locale;
require Psh::Util;

#
# Parse the command line and deal with the options except -r, which is
# handled in the MAIN program below. We do this part very early in this
# file so that the results apply to all the setting up we do before the
# MAIN program.
#
# option -i is ignored

@Psh::origINC=@INC; # save it

my %opt=();

if (@ARGV) {
	require Getopt::Std;
	Getopt::Std::getopts('Fiwrd:f:c:', \%opt);

	if ($opt{'r'}) {
		Psh::Util::print_error_i18n('no_r_flag');
		exit 1;
	}

	#
	# -w is "warnings mode":
	#

	if ($opt{'w'}) {
		Psh::Util::print_out_i18n('simulate_perl_w');
		$^W = 1;
		use strict;
	}

	#
	# -d is "debug mode":
	#

	if (exists($opt{'d'})) { $Psh::debugging = $opt{'d'}||'soie'; }
	else                   { $Psh::debugging = 0; }
}

Psh::Util::print_debug("Debugging!\n");

Psh::minimal_initialize;
Psh::process_rc($opt{'f'}) unless $opt{'F'};
Psh::finish_initialize;

# TODO: Is this implementation equivalent to sh's ?
if($opt{'c'}) {
	Psh::evl($opt{'c'});
	exit 0;
}

if (@ARGV) {
	Psh::process_args;
} else {
	Psh::initialize_interactive_mode;
	while (1) {
		eval { Psh::main_loop; };
		Psh::handle_message($@,'main_loop');
    }
}

exit 0;