Skip to content

Instantly share code, notes, and snippets.

Last active Aug 29, 2015
What would you like to do?
Watch a file and chown it once it exists
my $PATH = '.';
my $USER = 'muraiki';
my $GROUP = 'staff';
.unique(:as(*.path), :expires(1))\
.grep(* ~~ /\.sock/)\
.act(-> $socket {
say "Socket created: $socket"; # actually this happens for any I/O on the file, not just creation
my $chown_result = run 'chown', "$USER:$GROUP", $socket;
say $chown_result == 0 ?? "chown $socket succeeded" !! "chown $socket failed: " ~ $chown_result.exitcode;
exit $chown_result == 0 ?? 0 !! $chown_result.exitcode;
Copy link

muraiki commented Aug 25, 2015

The weirdness about checking the value of $chown_result is because run is returning an object on failure, which contradicts what's said in

This is true at least for perl6 version 2015.07.1-151-g5ad8122 built on MoarVM version 2015.07-57-gec051f5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment