aboutsummaryrefslogtreecommitdiff
path: root/toys/posix
diff options
context:
space:
mode:
Diffstat (limited to 'toys/posix')
-rw-r--r--toys/posix/chgrp.c2
-rw-r--r--toys/posix/grep.c4
-rw-r--r--toys/posix/id.c30
-rw-r--r--toys/posix/true.c2
4 files changed, 23 insertions, 15 deletions
diff --git a/toys/posix/chgrp.c b/toys/posix/chgrp.c
index 3aa25147..f573add4 100644
--- a/toys/posix/chgrp.c
+++ b/toys/posix/chgrp.c
@@ -8,7 +8,7 @@
* TODO: group only one of [HLP]
USE_CHGRP(NEWTOY(chgrp, "<2hPLHRfv", TOYFLAG_BIN))
-USE_CHGRP(OLDTOY(chown, chgrp, OPTSTR_chgrp, TOYFLAG_BIN))
+USE_CHGRP(OLDTOY(chown, chgrp, TOYFLAG_BIN))
config CHGRP
bool "chgrp/chown"
diff --git a/toys/posix/grep.c b/toys/posix/grep.c
index aba70878..18a27e3e 100644
--- a/toys/posix/grep.c
+++ b/toys/posix/grep.c
@@ -5,8 +5,8 @@
* See http://pubs.opengroup.org/onlinepubs/9699919799/utilities/grep.html
USE_GREP(NEWTOY(grep, "ZzEFHabhinorsvwclqe*f*m#x[!wx][!EFw]", TOYFLAG_BIN))
-USE_GREP(OLDTOY(egrep, grep, OPTSTR_grep, TOYFLAG_BIN))
-USE_GREP(OLDTOY(fgrep, grep, OPTSTR_grep, TOYFLAG_BIN))
+USE_GREP(OLDTOY(egrep, grep, TOYFLAG_BIN))
+USE_GREP(OLDTOY(fgrep, grep, TOYFLAG_BIN))
config GREP
bool "grep"
diff --git a/toys/posix/id.c b/toys/posix/id.c
index 000d7b4c..dd48cf0b 100644
--- a/toys/posix/id.c
+++ b/toys/posix/id.c
@@ -7,9 +7,9 @@
* See http://opengroup.org/onlinepubs/9699919799/utilities/id.html
USE_ID(NEWTOY(id, ">1nGgru[!Ggu]", TOYFLAG_BIN))
-USE_GROUPS(OLDTOY(groups, id, NULL, TOYFLAG_USR|TOYFLAG_BIN))
-USE_LOGNAME(OLDTOY(logname, id, ">0", TOYFLAG_BIN))
-USE_WHOAMI(OLDTOY(whoami, id, ">0", TOYFLAG_BIN))
+USE_GROUPS(NEWTOY(groups, NULL, TOYFLAG_USR|TOYFLAG_BIN))
+USE_LOGNAME(NEWTOY(logname, ">0", TOYFLAG_BIN))
+USE_WHOAMI(OLDTOY(whoami, logname, TOYFLAG_BIN))
config ID
bool "id"
@@ -133,15 +133,23 @@ void do_id(char *username)
void id_main(void)
{
// FLAG macros can be 0 if "id" command not enabled, so snapshot them here.
- if (FLAG_u) TT.do_u = toys.optflags & FLAG_u;
- if (FLAG_n) TT.do_n = toys.optflags & FLAG_n;
- if (FLAG_G) TT.do_G = toys.optflags & FLAG_G;
-
- // And set the variables for non-id commands.
- TT.is_groups = toys.which->name[0] == 'g';
- if (TT.is_groups) TT.do_G = TT.do_n = 1;
- else if (toys.which->name[0] != 'i') TT.do_u = TT.do_n = 1;
+ if (FLAG_u) TT.do_u |= toys.optflags & FLAG_u;
+ if (FLAG_n) TT.do_n |= toys.optflags & FLAG_n;
+ if (FLAG_G) TT.do_G |= toys.optflags & FLAG_G;
if (toys.optc) while(*toys.optargs) do_id(*toys.optargs++);
else do_id(NULL);
}
+
+void groups_main(void)
+{
+ TT.is_groups = 1;
+ TT.do_G = TT.do_n = 1;
+ id_main();
+}
+
+void logname_main(void)
+{
+ TT.do_u = TT.do_n = 1;
+ id_main();
+}
diff --git a/toys/posix/true.c b/toys/posix/true.c
index b22b7ac1..0fbb1786 100644
--- a/toys/posix/true.c
+++ b/toys/posix/true.c
@@ -5,7 +5,7 @@
* See http://opengroup.org/onlinepubs/9699919799/utilities/true.html
USE_TRUE(NEWTOY(true, NULL, TOYFLAG_BIN))
-USE_TRUE(OLDTOY(:, true, 0, TOYFLAG_NOFORK))
+USE_TRUE(OLDTOY(:, true, TOYFLAG_NOFORK))
config TRUE
bool "true"