updated git and svn scripts
[xrzperl.git] / r-run
blobb9a1327f7b70ad3239b387d009fc7a43ff52672c
1 #!/usr/bin/perl -w
2 ###APPNAME: r-run
3 ###APPAUTHOR: duel
4 ###APPDATE: 2009-02-23 00:48:38
5 ###APPVER: 0.1
6 ###APPDESC: r-run
7 ###APPUSAGE:
8 ###APPEXAMPLE: r-run
9 ###APPOPTION:
10 use strict;
12 #ENV variable MUST be defined somewhere,
13 #FOR perl to search modules from,
14 #OR nothing will work
15 use lib $ENV{XR_PERL_MODULE_DIR};
17 use MyPlace::Script::Usage qw/help_required help_even_empty/;
18 exit 0 if(help_required($0,@ARGV));
19 #exit 0 if(help_even_empty($0,@ARGV));
20 use MyPlace::ReEnterable;
21 my $hnd = MyPlace::ReEnterable->new('main');
23 sub process {
24 my $cmd = shift;
25 my $r=system($cmd,@_);
26 &sig_int if($r eq 2);
29 sub sig_int {
30 if($hnd->{lastStack}) {
31 $hnd->pushStack(@{$hnd->{lastStack}});
33 $hnd->saveToFile(".r-run.resume");
34 exit 1;
37 $SIG{INT}=\&sig_int;
40 unless($hnd->loadFromFile(".r-run.resume")) {
41 foreach(1 .. 10) {
42 $hnd->pushStack(undef,'process',"echo",$_);
44 $hnd->pushStack(undef,'process','ls','-a','-l');
45 $hnd->pushStack(undef,'process','cat');
46 $hnd->pushStack(undef,'process','help');
48 else {
49 print STDERR "Loading resume...\n";
51 until($hnd->isEmpty) {
52 $hnd->run();
54 unlink ".r-run.resume";
55 exit 0;