Skip to content

Commit

Permalink
support +PC --name program-name -PC and +PC --socket path-to-socket -PC
Browse files Browse the repository at this point in the history
in bin/pclient.pl
  • Loading branch information
pmurias committed Jul 13, 2010
1 parent 6a042d5 commit dd1b5c7
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions bin/pclient.pl
Expand Up @@ -7,8 +7,32 @@
use Term::ReadKey;
use Data::Dumper;
use Cwd qw(getcwd);

my $ARG_name = "pserver";
my $ARG_socket;

# anything between +PC and -PC is for us, everything else is for them
my (@args) = @ARGV;
my @argv;
while (@args) {
my $arg = shift @args;

if ($arg eq '+PC') {
while (@args || die("+PC must be closed by -PC\n") and (my $arg = shift(@args)) ne '-PC') {
if ($arg eq '--name') {
$ARG_name = shift(@args);
} elsif ($arg eq '--socket') {
$ARG_socket = shift(@args);
}
}
} else {
push(@argv,$arg);
}
}
my $socket_name = $ARG_socket // "/tmp/pserver-$ENV{USER}/$ARG_name";

socket(SERVER,PF_UNIX,SOCK_STREAM,0);
connect(SERVER, sockaddr_un('/tmp/pserver-pawel/pserver'));
connect(SERVER, sockaddr_un($socket_name));
sub input {
my ($rin,$win,$ein);
$rin = $win = $ein = '';
Expand All @@ -27,7 +51,7 @@ sub command {
select($oldfh);

command {ProgramName => "pserver"};
command {CommandLineArgs => \@ARGV};
command {CommandLineArgs => \@argv};
my @env;
while (my ($k,$v) = each %ENV) {
push @env,[$k,$v];
Expand Down

0 comments on commit dd1b5c7

Please sign in to comment.