That main function is good, standard style.
Unnecessary goto,
There is only one goto in chmod.c. If you consider it unnecessary, I'd
advise you to read the code again, and pay attention to the comment
explaining that particular chunk. (Hint: you can't break from more than
one control structure at once in C).
variables defined far away from where they are used,
That program was written before C99 allowed for variable declarations
in the middle of functions. There is currently no interest to move this
declarations for the sake of it.
monster function, variables are not commented what they do, not all
functions are commented what they do..
Does every simple base command need more comments than actual lines of
code?
To me, it looks like that there is no intention to optimize readability and
testability. Instead it looks like there is put effort to minimize amount of
functions or something.
There is indeed no such attempt. But the code is simple enough to be
understandable to anyone with correct knowledge of the C language and
brain cells in working condition.
It would be better if they all are put to separate functions. That is
the whole point in functions, to put task to single program fragment.
It would arguably be better, due to the linear structure of this particular
command. Also, when this command was written, BSD was running on some
architectures where function calls have a significant overhead.
Miod