aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2014-12-31 21:30:59 -0600
committerRob Landley <rob@landley.net>2014-12-31 21:30:59 -0600
commitf3e56f4e4ff773de95fa2c9daf979734d826fc33 (patch)
tree8a8e75b3530b504569ebe4fae09020073534c6db
parent5834ddd6df659d9c9dc7333284fc86762dea061a (diff)
downloadtoybox-f3e56f4e4ff773de95fa2c9daf979734d826fc33.tar.gz
Redo option parsing infrastructure so #define FORCE_FLAGS can unzero flag macros for a disabled command (needed when multiple commands share infrastructure with a common set of flags).
This means the flag space is no longer packed, but leaves gaps where the zeroes go. (Actual flag bit positions are the same for all configs.) Since the option parsing needs to know where the holes are, the OPTSTR values are now generated as part of flags.h with ascii 1 values for the disabled values. (So generated/oldflags.h went away.) This also means that the option string argument for OLDTOY() went away, it now uses the same arguments as the NEWTOY() it references.
-rw-r--r--lib/help.c2
-rw-r--r--main.c5
-rwxr-xr-xscripts/make.sh4
-rw-r--r--scripts/mkflags.c66
-rw-r--r--toys.h3
-rw-r--r--toys/other/dos2unix.c2
-rw-r--r--toys/other/nbd_client.c2
-rw-r--r--toys/other/netcat.c2
-rw-r--r--toys/other/reboot.c4
-rw-r--r--toys/pending/ftpget.c2
-rw-r--r--toys/pending/groupadd.c2
-rw-r--r--toys/pending/groupdel.c2
-rw-r--r--toys/pending/ip.c10
-rw-r--r--toys/pending/pgrep.c2
-rw-r--r--toys/pending/sh.c2
-rw-r--r--toys/pending/tcpsvd.c2
-rw-r--r--toys/pending/traceroute.c2
-rw-r--r--toys/pending/useradd.c2
-rw-r--r--toys/pending/userdel.c2
-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
23 files changed, 105 insertions, 51 deletions
diff --git a/lib/help.c b/lib/help.c
index 9965539d..b5d8f6b9 100644
--- a/lib/help.c
+++ b/lib/help.c
@@ -10,7 +10,7 @@ void show_help(void) {;}
#undef NEWTOY
#undef OLDTOY
#define NEWTOY(name,opt,flags) help_##name "\0"
-#define OLDTOY(name,oldname,opts,flags) "\xff" #oldname "\0"
+#define OLDTOY(name,oldname,flags) "\xff" #oldname "\0"
static char *help_data =
#include "generated/newtoys.h"
;
diff --git a/main.c b/main.c
index eefebf9e..dfab2f2a 100644
--- a/main.c
+++ b/main.c
@@ -10,7 +10,8 @@
#undef NEWTOY
#undef OLDTOY
#define NEWTOY(name, opts, flags) {#name, name##_main, opts, flags},
-#define OLDTOY(name, oldname, opts, flags) {#name, oldname##_main, opts, flags},
+#define OLDTOY(name, oldname, flags) \
+ {#name, oldname##_main, OPTSTR_##oldname, flags},
struct toy_list toy_list[] = {
#include "generated/newtoys.h"
@@ -57,7 +58,7 @@ struct toy_list *toy_find(char *name)
#undef NEWTOY
#undef OLDTOY
#define NEWTOY(name, opts, flags) opts ||
-#define OLDTOY(name, oldname, opts, flags) opts ||
+#define OLDTOY(name, oldname, flags) OPTSTR_##oldname ||
static const int NEED_OPTIONS =
#include "generated/newtoys.h"
0; // Ends the opts || opts || opts...
diff --git a/scripts/make.sh b/scripts/make.sh
index 1cbe5e0f..b91576ee 100755
--- a/scripts/make.sh
+++ b/scripts/make.sh
@@ -50,9 +50,7 @@ then
echo "USE_TOYBOX(NEWTOY(toybox, NULL, TOYFLAG_STAYROOT))" > generated/newtoys.h
sed -n -e 's/^USE_[A-Z0-9_]*(/&/p' toys/*/*.c \
| sed 's/\(.*TOY(\)\([^,]*\),\(.*\)/\2 \1\2,\3/' | sort -s -k 1,1 \
- | sed 's/[^ ]* //' >> generated/newtoys.h &&
- sed -n -e 's/.*(NEWTOY(\([^,]*\), *\(\("[^"]*"[^,]*\)*\),.*/#define OPTSTR_\1\t\2/p' \
- generated/newtoys.h > generated/oldtoys.h || exit 1
+ | sed 's/[^ ]* //' >> generated/newtoys.h || exit 1
fi
[ ! -z "$V" ] && echo "Which C files to build..."
diff --git a/scripts/mkflags.c b/scripts/mkflags.c
index 23cb83e8..454fc030 100644
--- a/scripts/mkflags.c
+++ b/scripts/mkflags.c
@@ -17,11 +17,42 @@ struct flag {
struct flag *lopt;
};
+// replace chopped out USE_BLAH() sections with low-ascii characters
+// showing how many flags got skipped
+
+char *mark_gaps(char *flags, char *all)
+{
+ char *n, *new, c;
+
+ // Shell feeds in " " for blank args, leading space not meaningful.
+ while (isspace(*flags)) flags++;
+ while (isspace(*all)) all++;
+
+ n = new = strdup(all);
+ while (*all) {
+ if (*flags == *all) {
+ *(new++) = *(all++);
+ *flags++;
+ continue;
+ }
+
+ c = *(all++);
+ if (strchr("?&^-:#|@*; ", c));
+ else if (strchr("=<>", c)) while (isdigit(*all)) all++;
+ else if (c == '(') while(*(all++) != ')');
+ else *(new++) = 1;
+ }
+ *new = 0;
+
+ return n;
+}
+
// Break down a command string into struct flag list.
struct flag *digest(char *string)
{
struct flag *list = NULL;
+ char *err = string;
while (*string) {
// Groups must be at end.
@@ -52,6 +83,10 @@ struct flag *digest(char *string)
if (strchr("?&^-:#|@*; ", *string)) string++;
else if (strchr("=<>", *string)) {
+ if (!isdigit(string[1])) {
+ fprintf(stderr, "%c without number in '%s'", *string, err);
+ exit(1);
+ }
while (isdigit(*++string)) {
if (!list) {
string++;
@@ -79,8 +114,12 @@ int main(int argc, char *argv[])
// See "intentionally crappy", above.
if (!(out = outbuf)) return 1;
+ printf("#ifdef FORCE_FLAGS\n#define FORCED_FLAG 1\n"
+ "#else\n#define FORCED_FLAG 0\n#endif\n\n");
+
for (;;) {
struct flag *flist, *aflist, *offlist;
+ char *gaps, *mgaps, c;
unsigned bit;
*command = 0;
@@ -95,6 +134,16 @@ int main(int argc, char *argv[])
bit = 0;
printf("// %s %s %s\n", command, flags, allflags);
+ mgaps = mark_gaps(flags, allflags);
+ for (gaps = mgaps; *gaps == 1; gaps++);
+ if (*gaps) c = '"';
+ else {
+ c = ' ';
+ gaps = "0";
+ }
+ printf("#undef OPTSTR_%s\n#define OPTSTR_%s %c%s%c\n",
+ command, command, c, gaps, c);
+ free(mgaps);
flist = digest(flags);
offlist = aflist = digest(allflags);
@@ -124,29 +173,28 @@ int main(int argc, char *argv[])
{
sprintf(out, "#define FLAG_%s (1<<%d)\n", flist->lopt->command, bit);
flist->lopt = flist->lopt->next;
- } else sprintf(out, "#define FLAG_%s 0\n", aflist->lopt->command);
+ } else sprintf(out, "#define FLAG_%s (FORCED_FLAG<<%d)\n",
+ aflist->lopt->command, bit);
aflist->lopt = aflist->lopt->next;
if (!aflist->command) {
aflist = aflist->next;
- if (flist) {
- flist = flist->next;
- bit++;
- }
+ bit++;
+ if (flist) flist = flist->next;
}
} else if (aflist->command) {
if (flist && (!aflist->command || *aflist->command == *flist->command))
{
if (aflist->command)
sprintf(out, "#define FLAG_%c (1<<%d)\n", *aflist->command, bit);
- bit++;
flist = flist->next;
- } else sprintf(out, "#define FLAG_%c 0\n", *aflist->command);
+ } else sprintf(out, "#define FLAG_%c (FORCED_FLAG<<%d)\n",
+ *aflist->command, bit);
+ bit++;
aflist = aflist->next;
}
out += strlen(out);
}
- sprintf(out, "#endif\n\n");
- out += strlen(out);
+ out = stpcpy(out, "#endif\n\n");
}
if (fflush(0) && ferror(stdout)) return 1;
diff --git a/toys.h b/toys.h
index 3b508497..6672cfcf 100644
--- a/toys.h
+++ b/toys.h
@@ -73,9 +73,8 @@
// Get list of function prototypes for all enabled command_main() functions.
#define NEWTOY(name, opts, flags) void name##_main(void);
-#define OLDTOY(name, oldname, opts, flags) void oldname##_main(void);
+#define OLDTOY(name, oldname, flags) void oldname##_main(void);
#include "generated/newtoys.h"
-#include "generated/oldtoys.h"
#include "generated/flags.h"
#include "generated/globals.h"
diff --git a/toys/other/dos2unix.c b/toys/other/dos2unix.c
index 3e1feb0e..690c5a8e 100644
--- a/toys/other/dos2unix.c
+++ b/toys/other/dos2unix.c
@@ -3,7 +3,7 @@
* Copyright 2012 Rob Landley <rob@landley.net>
USE_DOS2UNIX(NEWTOY(dos2unix, NULL, TOYFLAG_BIN))
-USE_DOS2UNIX(OLDTOY(unix2dos, dos2unix, NULL, TOYFLAG_BIN))
+USE_DOS2UNIX(OLDTOY(unix2dos, dos2unix, TOYFLAG_BIN))
config DOS2UNIX
bool "dos2unix/unix2dos"
diff --git a/toys/other/nbd_client.c b/toys/other/nbd_client.c
index 969ad4ae..c16585a2 100644
--- a/toys/other/nbd_client.c
+++ b/toys/other/nbd_client.c
@@ -8,7 +8,7 @@
// things like prototype "nbd-client_main" which isn't a valid symbol. So
// we hide the underscore name and OLDTOY the name we want.
USE_NBD_CLIENT(NEWTOY(nbd_client, "<3>3ns", 0))
-USE_NBD_CLIENT(OLDTOY(nbd-client, nbd_client, OPTSTR_nbd_client, TOYFLAG_USR|TOYFLAG_BIN))
+USE_NBD_CLIENT(OLDTOY(nbd-client, nbd_client, TOYFLAG_USR|TOYFLAG_BIN))
config NBD_CLIENT
bool "nbd-client"
diff --git a/toys/other/netcat.c b/toys/other/netcat.c
index 2c1ec7b2..58f08251 100644
--- a/toys/other/netcat.c
+++ b/toys/other/netcat.c
@@ -4,7 +4,7 @@
*
* TODO: udp, ipv6, genericize for telnet/microcom/tail-f
-USE_NETCAT(OLDTOY(nc, netcat, USE_NETCAT_LISTEN("tl^L^")"w#p#s:q#f:", TOYFLAG_BIN))
+USE_NETCAT(OLDTOY(nc, netcat, TOYFLAG_BIN))
USE_NETCAT(NEWTOY(netcat, USE_NETCAT_LISTEN("tl^L^")"w#p#s:q#f:", TOYFLAG_BIN))
config NETCAT
diff --git a/toys/other/reboot.c b/toys/other/reboot.c
index 5cbc4f87..8baa4d8a 100644
--- a/toys/other/reboot.c
+++ b/toys/other/reboot.c
@@ -3,8 +3,8 @@
* Copyright 2013 Elie De Brauwer <eliedebrauwer@gmail.com>
USE_REBOOT(NEWTOY(reboot, "n", TOYFLAG_BIN|TOYFLAG_NEEDROOT))
-USE_REBOOT(OLDTOY(halt, reboot, "n", TOYFLAG_BIN|TOYFLAG_NEEDROOT))
-USE_REBOOT(OLDTOY(poweroff, reboot, "n", TOYFLAG_BIN|TOYFLAG_NEEDROOT))
+USE_REBOOT(OLDTOY(halt, reboot, TOYFLAG_BIN|TOYFLAG_NEEDROOT))
+USE_REBOOT(OLDTOY(poweroff, reboot, TOYFLAG_BIN|TOYFLAG_NEEDROOT))
config REBOOT
bool "reboot"
diff --git a/toys/pending/ftpget.c b/toys/pending/ftpget.c
index 2a81a34a..a1447139 100644
--- a/toys/pending/ftpget.c
+++ b/toys/pending/ftpget.c
@@ -6,7 +6,7 @@
* No Standard.
*
USE_FTPGET(NEWTOY(ftpget, "<2cvu:p:P#<0=21>65535", TOYFLAG_BIN))
-USE_FTPGET(OLDTOY(ftpput,ftpget, "<2vu:p:P#<0=21>65535", TOYFLAG_BIN))
+USE_FTPGET(OLDTOY(ftpput, ftpget, TOYFLAG_BIN))
config FTPGET
bool "ftpget/ftpput"
diff --git a/toys/pending/groupadd.c b/toys/pending/groupadd.c
index 7df0a5c3..615c12f8 100644
--- a/toys/pending/groupadd.c
+++ b/toys/pending/groupadd.c
@@ -6,7 +6,7 @@
* See http://refspecs.linuxfoundation.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/groupadd.html
USE_GROUPADD(NEWTOY(groupadd, "<1>2g#<0S", TOYFLAG_NEEDROOT|TOYFLAG_SBIN))
-USE_GROUPADD(OLDTOY(addgroup, groupadd, OPTSTR_groupadd, TOYFLAG_NEEDROOT|TOYFLAG_SBIN))
+USE_GROUPADD(OLDTOY(addgroup, groupadd, TOYFLAG_NEEDROOT|TOYFLAG_SBIN))
config GROUPADD
bool "groupadd"
diff --git a/toys/pending/groupdel.c b/toys/pending/groupdel.c
index 834e113e..483ac59c 100644
--- a/toys/pending/groupdel.c
+++ b/toys/pending/groupdel.c
@@ -6,7 +6,7 @@
* See http://refspecs.linuxfoundation.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/groupdel.html
USE_GROUPDEL(NEWTOY(groupdel, "<1>2", TOYFLAG_NEEDROOT|TOYFLAG_SBIN))
-USE_GROUPDEL(OLDTOY(delgroup, groupdel, OPTSTR_groupdel, TOYFLAG_NEEDROOT|TOYFLAG_SBIN))
+USE_GROUPDEL(OLDTOY(delgroup, groupdel, TOYFLAG_NEEDROOT|TOYFLAG_SBIN))
config GROUPDEL
bool "groupdel"
diff --git a/toys/pending/ip.c b/toys/pending/ip.c
index 42d3a734..be4d8bba 100644
--- a/toys/pending/ip.c
+++ b/toys/pending/ip.c
@@ -8,11 +8,11 @@
* No Standard.
*
USE_IP(NEWTOY(ip, NULL, TOYFLAG_SBIN))
-USE_IP(OLDTOY(ipaddr, ip, NULL, TOYFLAG_SBIN))
-USE_IP(OLDTOY(iplink, ip, NULL, TOYFLAG_SBIN))
-USE_IP(OLDTOY(iproute, ip, NULL, TOYFLAG_SBIN))
-USE_IP(OLDTOY(iprule, ip, NULL, TOYFLAG_SBIN))
-USE_IP(OLDTOY(iptunnel, ip, NULL, TOYFLAG_SBIN))
+USE_IP(OLDTOY(ipaddr, ip, TOYFLAG_SBIN))
+USE_IP(OLDTOY(iplink, ip, TOYFLAG_SBIN))
+USE_IP(OLDTOY(iproute, ip, TOYFLAG_SBIN))
+USE_IP(OLDTOY(iprule, ip, TOYFLAG_SBIN))
+USE_IP(OLDTOY(iptunnel, ip, TOYFLAG_SBIN))
config IP
bool "ip"
diff --git a/toys/pending/pgrep.c b/toys/pending/pgrep.c
index 77b6cede..59767b9f 100644
--- a/toys/pending/pgrep.c
+++ b/toys/pending/pgrep.c
@@ -5,7 +5,7 @@
*
USE_PGREP(NEWTOY(pgrep, "?P# s# xvonlf[!sP]", TOYFLAG_USR|TOYFLAG_BIN))
-USE_PGREP(OLDTOY(pkill, pgrep, OPTSTR_pgrep, TOYFLAG_USR|TOYFLAG_BIN))
+USE_PGREP(OLDTOY(pkill, pgrep, TOYFLAG_USR|TOYFLAG_BIN))
config PGREP
bool "pgrep"
diff --git a/toys/pending/sh.c b/toys/pending/sh.c
index 81f91a7b..a234e5b9 100644
--- a/toys/pending/sh.c
+++ b/toys/pending/sh.c
@@ -25,7 +25,7 @@ USE_SH(NEWTOY(cd, NULL, TOYFLAG_NOFORK))
USE_SH(NEWTOY(exit, NULL, TOYFLAG_NOFORK))
USE_SH(NEWTOY(sh, "c:"USE_SH_INTERACTIVE("i"), TOYFLAG_BIN))
-USE_SH(OLDTOY(toysh, sh, OPTSTR_sh, TOYFLAG_BIN))
+USE_SH(OLDTOY(toysh, sh, TOYFLAG_BIN))
config SH
bool "sh (toysh)"
diff --git a/toys/pending/tcpsvd.c b/toys/pending/tcpsvd.c
index d7e1f6c1..585ae733 100644
--- a/toys/pending/tcpsvd.c
+++ b/toys/pending/tcpsvd.c
@@ -7,7 +7,7 @@
* No Standard.
USE_TCPSVD(NEWTOY(tcpsvd, "^<3c#=30<1C:b#=20<0u:l:hEv", TOYFLAG_USR|TOYFLAG_BIN))
-USE_TCPSVD(OLDTOY(udpsvd, tcpsvd, OPTSTR_tcpsvd, TOYFLAG_USR|TOYFLAG_BIN))
+USE_TCPSVD(OLDTOY(udpsvd, tcpsvd, TOYFLAG_USR|TOYFLAG_BIN))
config TCPSVD
bool "tcpsvd"
diff --git a/toys/pending/traceroute.c b/toys/pending/traceroute.c
index 92509930..830331a5 100644
--- a/toys/pending/traceroute.c
+++ b/toys/pending/traceroute.c
@@ -8,7 +8,7 @@
* No Standard
USE_TRACEROUTE(NEWTOY(traceroute, "<1>2i:f#<1>255=1z#<0>86400=0g*w#<0>86400=5t#<0>255=0s:q#<1>255=3p#<1>65535=33434m#<1>255=30rvndlIUF64", TOYFLAG_STAYROOT|TOYFLAG_USR|TOYFLAG_BIN))
-USE_TRACEROUTE(OLDTOY(traceroute6,traceroute, OPTSTR_traceroute, TOYFLAG_STAYROOT|TOYFLAG_USR|TOYFLAG_BIN))
+USE_TRACEROUTE(OLDTOY(traceroute6,traceroute, TOYFLAG_STAYROOT|TOYFLAG_USR|TOYFLAG_BIN))
config TRACEROUTE
bool "traceroute"
default n
diff --git a/toys/pending/useradd.c b/toys/pending/useradd.c
index 4f2bcc61..78f083b7 100644
--- a/toys/pending/useradd.c
+++ b/toys/pending/useradd.c
@@ -6,7 +6,7 @@
* See http://refspecs.linuxfoundation.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/useradd.html
USE_USERADD(NEWTOY(useradd, "<1>2u#<0G:s:g:h:SDH", TOYFLAG_NEEDROOT|TOYFLAG_UMASK|TOYFLAG_SBIN))
-USE_USERADD(OLDTOY(adduser, useradd, OPTSTR_useradd, TOYFLAG_NEEDROOT|TOYFLAG_UMASK|TOYFLAG_SBIN))
+USE_USERADD(OLDTOY(adduser, useradd, TOYFLAG_NEEDROOT|TOYFLAG_UMASK|TOYFLAG_SBIN))
config USERADD
bool "useradd"
diff --git a/toys/pending/userdel.c b/toys/pending/userdel.c
index 8619a620..9c93a219 100644
--- a/toys/pending/userdel.c
+++ b/toys/pending/userdel.c
@@ -5,7 +5,7 @@
* See http://refspecs.linuxfoundation.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/userdel.html
USE_USERDEL(NEWTOY(userdel, "<1>1r", TOYFLAG_NEEDROOT|TOYFLAG_SBIN))
-USE_USERDEL(OLDTOY(deluser, userdel, OPTSTR_userdel, TOYFLAG_NEEDROOT|TOYFLAG_SBIN))
+USE_USERDEL(OLDTOY(deluser, userdel, TOYFLAG_NEEDROOT|TOYFLAG_SBIN))
config USERDEL
bool "userdel"
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"