!*$ * M[getopt] -> First non-flag argument -- Parse options * * Parses command line options according to the string * \(lqoptstring\(rq, similar to \fBgetopt\P(3). * \(lqoptstring\(rq is a list of single character * option names. * If followed by a colon, the option takes an argument * (which can be part of the same command line argument as in * \(lq-Ofoo\(rq). * If followed by two colons, the option argument is optional. * For every detected option \fIX\fP, a register \fBgetopt.\fIX\fR is * defined with -1 (true) in its integer part. * If the option had an argument, it is stored in the register's * string part. * * Returns the index of the first command-line argument that does not * belong to a flag or -1 in case of parsing errors. *! [optstring] @[getopt]{ <%.j :Q[\.j]:; 0Q[\.j]--"N 1; ' !next! 1Q[\.j]U.f Q.f--"= !* -- *! Q.j+1 ' !* j-th argument is -f *! 0U.i < Q.iQ[optstring]U.o Q.o"< -1 ' !* count number of : after o *! 0U.#ar <%.iQ[optstring]-:"N 1; ' %.#ar> Q.f-Q.o"= -U[getopt.U.o] Q.#ar"> 2Q[\.j]"< !* -f arg *! %.j Q.#ar-1"> !* optional arg *! :Q[\.j]"< Q.j ' 0Q[\.j]--"= Onext ' | :Q[\.j]"< -1 ' ' EU[getopt.U.o]Q[\.j] | !* -farg *! EU[getopt.U.o]Q[\.j] [* EQ[getopt.U.o] 2D ]* ' ' 1; ' > > Q.j}