# HG changeset patch # User Rob Landley # Date 1214538523 18000 # Node ID 93223118c81390daa5e1bf5aeb578a7b3c5168c5 # Parent b8f6dd7cf7f74f4159802297c3d963034bae9a6f Option parsing: stopearly is now a ^ prefix (not +), and an option string with no flags auto-enables stopearly (so seq doesn't have to specify it to avoid having negative number arguments eaten by the option parsing logic). diff -r b8f6dd7cf7f7 -r 93223118c813 lib/args.c --- a/lib/args.c Sun Jun 22 04:18:39 2008 -0500 +++ b/lib/args.c Thu Jun 26 22:48:43 2008 -0500 @@ -25,7 +25,7 @@ // !X die with error if X already set (x!x die if x supplied twice) // [yz] needs at least one of y or z. // at the beginning: -// + stop at first nonoption argument +// ^ stop at first nonoption argument // <0 at least # leftover arguments needed (default 0) // >9 at most # leftover arguments needed (default MAX_INT) // ? don't show_usage() on unknown argument. @@ -167,7 +167,7 @@ // Parse leading special behavior indicators for (;;) { - if (*options == '+') stopearly++; + if (*options == '^') stopearly++; else if (*options == '<') minargs=*(++options)-'0'; else if (*options == '>') maxargs=*(++options)-'0'; else if (*options == '?') gof.noerror++; @@ -176,6 +176,7 @@ options++; } + if (!*options) stopearly++; // Parse rest of opts into array while (*options) { char *temp; diff -r b8f6dd7cf7f7 -r 93223118c813 toys/echo.c --- a/toys/echo.c Sun Jun 22 04:18:39 2008 -0500 +++ b/toys/echo.c Thu Jun 26 22:48:43 2008 -0500 @@ -6,7 +6,7 @@ * * See http://www.opengroup.org/onlinepubs/009695399/utilities/echo.html -USE_ECHO(NEWTOY(echo, "+?en", TOYFLAG_BIN)) +USE_ECHO(NEWTOY(echo, "^?en", TOYFLAG_BIN)) config ECHO bool "echo" diff -r b8f6dd7cf7f7 -r 93223118c813 toys/oneit.c --- a/toys/oneit.c Sun Jun 22 04:18:39 2008 -0500 +++ b/toys/oneit.c Thu Jun 26 22:48:43 2008 -0500 @@ -6,7 +6,7 @@ * * Not in SUSv3. -USE_ONEIT(NEWTOY(oneit, "+<1c:p", TOYFLAG_SBIN)) +USE_ONEIT(NEWTOY(oneit, "^<1c:p", TOYFLAG_SBIN)) config ONEIT bool "oneit" diff -r b8f6dd7cf7f7 -r 93223118c813 toys/seq.c --- a/toys/seq.c Sun Jun 22 04:18:39 2008 -0500 +++ b/toys/seq.c Thu Jun 26 22:48:43 2008 -0500 @@ -6,7 +6,7 @@ * * Not in SUSv3. (Don't ask me why not.) -USE_SEQ(NEWTOY(seq, "<1>3?+", TOYFLAG_USR|TOYFLAG_BIN)) +USE_SEQ(NEWTOY(seq, "<1>3?", TOYFLAG_USR|TOYFLAG_BIN)) config SEQ bool "seq"