In Crystal, I am comparing certain files. I want to see if the file.a
has the same owner as file.b
. I thought I would use File.info("file.a").owner
. However, I haven't found a way to get the uid of the user of the current process, other than starting another process:
`id -u #{`whoami`.strip}`
Is there a native way?
Currently, an API method to access the process' current user is missing. But there is an open PR on the Github repository which declares a Process.user
method.
For now, you can either shell out as demonstrated in the question or apply the patch from the mentioned PR to your source code. And hopefully it will be included in the next Crystal release.