Pádraig Brady <[email protected]> writes: > Yes it's probably better like this to emphasize you > can't combine the "am I" with a file. > Though you can on FreeBSD I see. > I.e. it supports [ARG1 ARG2] [FILE]. > I don't see why we couldn't support that too.
Interesting. It seems that is a FreeBSD (and macOS as a result) specific feature. At least, I checked NetBSD 10.1, OpenBSD 7.8, and Solaris 11.4, which don't allow "am i" along with a file. I also checked AIX 7.3, but it seems to not have anything other than GNU 'who'. I guess the rationale is being able to get the currently logged-in user from a utmp, or equivalent, file other than the default? Admittedly, I haven't used 'who' with a file much, but it seems useful enough to make the relatively simple change to support it. > I also notice we've no tests for who! Yes, I think I noticed that a while ago as well. Probably because the APIs are very platform specific, and vary across distributions even. E.g., the recent threads regarding Ubuntu and Debian. Though on platforms with the utmpname function, I think we can use it to write a temporary utmp file for testing. Jia Tan would just commit utmp files directly, but let's not follow in his footsteps > I also notice we don't verify file access? (FreeBSD does) > > $ who /var/log/wtmp.typo; echo $? > 0 Ah, in gnulib lib/readutmp.c, for the call to UTMP_NAME_FUNCTION, you can see a comment explaining why. Basically, some implementations don't return a value, and others return different values when the open fails. I guess we could add a configure check, as long as we are okay with the behavior being different on old glibc versions that don't return a value. Collin
