aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2013-09-21 13:46:44 -0500
committerRob Landley <rob@landley.net>2013-09-21 13:46:44 -0500
commitc705b95cef54b13f2caf801d929207ec7f5fbce7 (patch)
treecd7457c9abb83b86fd320a94b7416f7204d3ae79
parentdc6db1a81ab2642927a2c431b7ffab120eeb92ca (diff)
downloadtoybox-c705b95cef54b13f2caf801d929207ec7f5fbce7.tar.gz
Tweak args (yank old + that never worked, rename | to +), and add uname -o as a synonym for -s.
-rw-r--r--lib/args.c16
-rw-r--r--toys/posix/uname.c2
2 files changed, 6 insertions, 12 deletions
diff --git a/lib/args.c b/lib/args.c
index 26de5665..16eb48ad 100644
--- a/lib/args.c
+++ b/lib/args.c
@@ -79,9 +79,8 @@
//
// At the end: [groups] of previously seen options
// - Only one in group (switch off) [-abc] means -ab=-b, -ba=-a, -abc=-c
-// | Synonyms (switch on all) [|abc] means -ab=-abc, -c=-abc
+// + Synonyms (switch on all) [+abc] means -ab=-abc, -c=-abc
// ! More than one in group is error [!abc] means -ab calls error_exit()
-// + First in group switches rest on [+abc] means -a=-abc, -b=-b, -c=-c
// primarily useful if you can switch things back off again.
//
@@ -339,14 +338,14 @@ void parse_optflaglist(struct getoptflagstate *gof)
if (CFG_TOYBOX_DEBUG && *options != '[') error_exit("trailing %s", options);
- idx = stridx("-|!+", *++options);
+ idx = stridx("-+!", *++options);
if (CFG_TOYBOX_DEBUG && idx == -1) error_exit("[ needs +-!");
- if (CFG_TOYBOX_DEBUG && (*options == ']' || !options))
+ if (CFG_TOYBOX_DEBUG && (options[1] == ']' || !options[1]))
error_exit("empty []");
// Don't advance past ] but do process it once in loop.
- while (*(options++) != ']') {
- struct opts *opt, *opt2 = 0;
+ while (*options++ != ']') {
+ struct opts *opt;
int i;
if (CFG_TOYBOX_DEBUG && !*options) error_exit("[ without ]");
@@ -354,17 +353,12 @@ void parse_optflaglist(struct getoptflagstate *gof)
for (i=0, opt = gof->opts; ; i++, opt = opt->next) {
if (*options == ']') {
if (!opt) break;
- if (idx == 3) {
- opt2->dex[1] |= bits;
- break;
- }
if (bits&(1<<i)) opt->dex[idx] |= bits&~(1<<i);
} else {
if (CFG_TOYBOX_DEBUG && !opt)
error_exit("[] unknown target %c", *options);
if (opt->c == *options) {
bits |= 1<<i;
- if (!opt2) opt2=opt;
break;
}
}
diff --git a/toys/posix/uname.c b/toys/posix/uname.c
index cd33f12b..2e17d387 100644
--- a/toys/posix/uname.c
+++ b/toys/posix/uname.c
@@ -4,7 +4,7 @@
*
* See http://opengroup.org/onlinepubs/9699919799/utilities/uname.html
-USE_UNAME(NEWTOY(uname, "amvrns", TOYFLAG_BIN))
+USE_UNAME(NEWTOY(uname, "oamvrns[+os]", TOYFLAG_BIN))
config UNAME
bool "uname"