#! /usr/bin/perl
#
# psh - Perl Shell
#
# Copyright (C) 1999-2000 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 locale;
use Psh;
use Psh::Locale::Base;
use Getopt::Std;

use vars qw($VERSION %opt);

$VERSION='0.008';

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

getopts('iwrd: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'}||'soi'; }
else                   { $Psh::debugging = 0; }

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

Psh::minimal_initialize;
Psh::process_rc($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 {
	while (1) {
		eval { Psh::main_loop; };
		Psh::handle_message($@,'main_loop');
    }
}

exit 0;



# The following is for Emacs - I hope it won't annoy anyone
# but this could solve the problems with different tab widths etc
#
# Local Variables:
# tab-width:4
# indent-tabs-mode:t
# c-basic-offset:4
# perl-indent-level:4
# End:

