#!/usr/bin/perl -w
#
# __copy1__
# __copy2__
#
# executes a program in a old-fashioned terminal (xterm, green on black),
# it's written in perl to avoid any strange shell arguments expansion
#
my $size	= "130x10";
my $pos		= "+100-100";
my $geometry	= $size . $pos;
my @cmd;

ARGS: while (scalar(@ARGV)) {
    CASE: {
    $_ = shift(@ARGV);
	if ($_ eq "--size") {
    		usage()	if (!defined $ARGV[0]);
		$size		= shift(@ARGV);
		$geometry	= $size . $pos;
		last CASE;
	}
	if ($_ eq "--pos") {
    		usage()	if (!defined $ARGV[0]);
		$pos		= shift(@ARGV);
		if ($pos eq "TL") { $pos = "+30+30"; }
		if ($pos eq "TR") { $pos = "-30+30"; }
		if ($pos eq "BL") { $pos = "+30-30"; }
		if ($pos eq "BR") { $pos = "-30-30"; }
		$geometry	= $size . $pos;
		last CASE;
	}
	if ($_ eq "--geometry") {
    		usage()	if (!defined $ARGV[0]);
		$geometry	= shift(@ARGV);
		last CASE;
	}
	if ($_ eq "--")		{ last ARGS; }
	if ($_ =~ "^[^-]")	{ push( @cmd, $_ ); last ARGS; }
	if ($_ =~ /^-/)		{ usage(); }
	push( @cmd, $_ );
    }
}
push( @cmd, @ARGV );

usage()	if (!@cmd);

system( "xterm", "+sb",
	"-geometry", $geometry,
	"-fn", "10x20",
	"-bg", "black",
	"-fg", "green3",
	"-e", @cmd ) and exit(1);

exit(0);




sub usage
{
	die "
usage: $0 [options] command

options:
  --size XxY		set size	now: $size
  --pos {-+}X{-+}Y	set position	now: $pos
  --geometry geometry	size&position	now: $geometry
  --			stops options parsing

pos can accept these values also:

  TL (Top Left)		TR (Top Right)
  BL (Bottom Left)	BR (Bottom Right)
";
}
