The Unix `Who` Command
11–20 of 43 posts
Re: The Unix `Who` Command
#12Earlier quoted context omitted.
> Of course, this only mocks the most basic features of the who command and doesn’t handle any option, like the famous `who am i` or `who mom hates`. it's not quite an apples to apples comparison as his rewrite doesn't handle any options or cleverness, but it's still a massive jump in LOC.
Nor is it anywhere near as portability. Though that's not a big issue these days.
Re: The Unix `Who` Command
#13I was confused - is "who mom hates" supposed to do something interesting? On my Mac it seems any two arguments are allowed as an alias for "am i", so long as the first doesn't start with "-". Looking it up, https://unix.stackexchange.com/questions/108145/is-who-mom-l... suggests it's a well-known in-joke. FWIW, on my FreeBSD machine, only "who am i"/"who am I" are allowed.
Re: The Unix `Who` Command
#14His "who" implementation is 73 lines (21 if you remove blank lines and comments). Compare that to 836 in GNU Coreutils[0]. [0] https://github.com/coreutils/coreutils/blob/master/src/who.c
I see some comments here citing a lack of options, most of which appear to have nothing to do with who is logged into the machine.
Re: The Unix `Who` Command
#15who is the focus of Chapter 2.
Re: The Unix `Who` Command
#16His "who" implementation is 73 lines (21 if you remove blank lines and comments). Compare that to 836 in GNU Coreutils[0]. [0] https://github.com/coreutils/coreutils/blob/master/src/who.c
Re: The Unix `Who` Command
#17I was confused - is "who mom hates" supposed to do something interesting? On my Mac it seems any two arguments are allowed as an alias for "am i", so long as the first doesn't start with "-". Looking it up, https://unix.stackexchange.com/questions/108145/is-who-mom-l... suggests it's a well-known in-joke. FWIW, on my FreeBSD machine, only "who am i"/"who am I" are allowed.
Re: The Unix `Who` Command
#18His "who" implementation is 73 lines (21 if you remove blank lines and comments). Compare that to 836 in GNU Coreutils[0]. [0] https://github.com/coreutils/coreutils/blob/master/src/who.c
plan 9 who is a 3 line shell script that just greps the output of ps and sorts it. You could eliminate ps and just grep through /proc but why reinvent the wheel when an existing tool already does part of the job? I see some comments here citing a lack of options, most of which appear to have nothing to do with who is logged into the machine.
Re: The Unix `Who` Command
#19His "who" implementation is 73 lines (21 if you remove blank lines and comments). Compare that to 836 in GNU Coreutils[0]. [0] https://github.com/coreutils/coreutils/blob/master/src/who.c
plan 9 who is a 3 line shell script that just greps the output of ps and sorts it. You could eliminate ps and just grep through /proc but why reinvent the wheel when an existing tool already does part of the job? I see some comments here citing a lack of options, most of which appear to have nothing to do with who is logged into the machine.
Re: The Unix `Who` Command
#20I love your simple demonstration of strace reverse engineering a UNIX command. Probably a very silly question but I get this compile error? mywho.c:8:13: error: use of undeclared identifier 'LC_ALL' setlocale(LC_ALL, ""); I should solve it myself but since you are here?