Question for fellow Shell experts: Is there a POSIX-portable utility to find another user's home directory? I am looking for an alternative to ~user in scripts.

#shell #posix #linux #unix

Follow

@awb

I would use `getent passwd`, which is apparently expected by POSIX (but I don't know whether POSIX prescribes its output format).

@robryk I don't believe there is a general getent utility in POSIX, just a getpwent system call, which the standard advises against using and recommends getpwuid instead.

@awb

Hm, you are right. I must have misread the manpage (I thought it claimed that it's a POSIX-mandated utility).

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.