Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Take #2 on implementing $*USER and $*GROUP
Please note that this adds one qx() for every start.  Somehow, I can't get
this to be on-demand using Proxy.  Pointers in that direction welcome!
  • Loading branch information
lizmat committed Jun 3, 2014
1 parent d78b631 commit 17f0230
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/core/Process.pm
Expand Up @@ -22,6 +22,41 @@
PROCESS::<$PROGRAM_NAME> = $PROGRAM_NAME;

PROCESS::<$TMPDIR> = IO::Spec.tmpdir().path;

class IdName {
has Int $.id;
has Str $.name;

method Numeric { $!id }
method Str { $!name }
method gist { "$!name ($!id)" }
}

# probably needs some nqp::op, LHF for someone?
if try { qx/id/ } -> $id {
if $id ~~ m/^
[ uid "=" $<uid>=(\d+) ]
[ "(" $<user>=(<-[ ) ]>+) ")" ]
\s+
[ gid "=" $<gid>=(\d+) ]
[ "(" $<group>=(<-[ ) ]>+) ")" ]
/ {
PROCESS::<$USER> := IdName.new( :id(+$<uid>), :name(~$<user>) );
PROCESS::<$GROUP> := IdName.new( :id(+$<gid>), :name(~$<group>) );
}

# alas, no support yet
else {
PROCESS::<$USER> := Nil;
PROCESS::<$GROUP> := Nil;
}
}

# alas, no support yet
else {
PROCESS::<$USER> := Nil;
PROCESS::<$GROUP> := Nil;
}
}

# vim: ft=perl6 expandtab sw=4

0 comments on commit 17f0230

Please sign in to comment.