aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2008-06-26 22:48:43 -0500
committerRob Landley <rob@landley.net>2008-06-26 22:48:43 -0500
commitb1487dc9ed8c892afde94a8ac04350e3ca0e7074 (patch)
treef9e041f48ececa6e63decbd2957394275f81d3e6
parentf901f24334ee8c0f03b72c2a1ad365b61334db5a (diff)
downloadtoybox-b1487dc9ed8c892afde94a8ac04350e3ca0e7074.tar.gz
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).
-rw-r--r--lib/args.c5
-rw-r--r--toys/echo.c2
-rw-r--r--toys/oneit.c2
-rw-r--r--toys/seq.c2
4 files changed, 6 insertions, 5 deletions
diff --git a/lib/args.c b/lib/args.c
index ee915b46..60b99d20 100644
--- a/lib/args.c
+++ b/lib/args.c
@@ -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 @@ void get_optflags(void)
// 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 @@ void get_optflags(void)
options++;
}
+ if (!*options) stopearly++;
// Parse rest of opts into array
while (*options) {
char *temp;
diff --git a/toys/echo.c b/toys/echo.c
index fda008af..5feb9899 100644
--- a/toys/echo.c
+++ b/toys/echo.c
@@ -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 --git a/toys/oneit.c b/toys/oneit.c
index 4c36491f..341bb080 100644
--- a/toys/oneit.c
+++ b/toys/oneit.c
@@ -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 --git a/toys/seq.c b/toys/seq.c
index 8eb8fb8e..ced5e8fb 100644
--- a/toys/seq.c
+++ b/toys/seq.c
@@ -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"