Re:How Old School C Programmers Process Arguments
by henesy on Sunday January 28, 2018 @04:39AM
(#16250590)
The Plan 9 solution always felt really logical imo.
Re:How Old School C Programmers Process Arguments
by mjl- on Sunday January 28, 2018 @04:50AM
(#16250615)
i agree. too "clever", feels like a needless optimization. (optimizing for fewer keystrokes to type? or obscurity?)
btw, many of the plan 9 commands use slightly different/custom option parsing. probably for historic reasons.
Re:How Old School C Programmers Process Arguments
by mveety on Sunday January 28, 2018 @12:52PM
(#16252310)
No, this isn't clever at all. Its an optimization for when you need to write a lot of little utilities that need to parse arguments. It probably came out of a day of writing tools, and after the fifth time of rewriting that while/for loop someone got pissed and made that macro. I use this macro all the time on both 9front and unix because it makes parsing arguments trivial (and I don't use long options, but that's more because I'm a plan 9/unix extremist than for any technical reasons).
ARGBEGIN{ default: usage(); case 'm': m = ARGF(); break; case 'p': pflag = 1; break; }ARGEND
https://github.com/9fans/plan9port/blob/master/include/libc.... https://github.com/9fans/plan9port/blob/master/src/cmd/mkdir...