aboutsummaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2021-04-02 14:26:24 -0700
committerElliott Hughes <enh@google.com>2021-04-02 14:36:19 -0700
commit29ae04250e7f0af8eaa7a4e70a65d1ca9cdaf373 (patch)
tree5eace784c9d65d1ca432ac3c12156f2c3812df6c /android
parent7b76a4f414babb51fc32002a1d63a0990bffe18e (diff)
parentaa16e0e2ccb366835c2aec0cb2f6e0e52497ede5 (diff)
downloadtoybox-29ae04250e7f0af8eaa7a4e70a65d1ca9cdaf373.tar.gz
Merge remote-tracking branch 'toybox/master' into HEAD
Change-Id: I14eea373d1242bc16afafc4ddc6ca305ef6b044e
Diffstat (limited to 'android')
-rw-r--r--android/device/generated/config.h2
-rw-r--r--android/device/generated/flags.h20
-rw-r--r--android/device/generated/globals.h50
-rw-r--r--android/device/generated/help.h4
-rw-r--r--android/device/generated/newtoys.h3
-rw-r--r--android/linux/generated/config.h2
-rw-r--r--android/linux/generated/flags.h20
-rw-r--r--android/linux/generated/globals.h50
-rw-r--r--android/linux/generated/help.h4
-rw-r--r--android/linux/generated/newtoys.h3
-rw-r--r--android/mac/generated/config.h2
-rw-r--r--android/mac/generated/flags.h20
-rw-r--r--android/mac/generated/globals.h50
-rw-r--r--android/mac/generated/help.h4
-rw-r--r--android/mac/generated/newtoys.h3
15 files changed, 159 insertions, 78 deletions
diff --git a/android/device/generated/config.h b/android/device/generated/config.h
index 24afbf4a..d7d0b831 100644
--- a/android/device/generated/config.h
+++ b/android/device/generated/config.h
@@ -108,6 +108,8 @@
#define USE_CHROOT(...) __VA_ARGS__
#define CFG_CHRT 1
#define USE_CHRT(...) __VA_ARGS__
+#define CFG_CHSH 0
+#define USE_CHSH(...)
#define CFG_CHVT 0
#define USE_CHVT(...)
#define CFG_CKSUM 1
diff --git a/android/device/generated/flags.h b/android/device/generated/flags.h
index c7151866..d0fa452b 100644
--- a/android/device/generated/flags.h
+++ b/android/device/generated/flags.h
@@ -314,6 +314,15 @@
#undef FLAG_m
#endif
+// chsh s:
+#undef OPTSTR_chsh
+#define OPTSTR_chsh "s:"
+#ifdef CLEANUP_chsh
+#undef CLEANUP_chsh
+#undef FOR_chsh
+#undef FLAG_s
+#endif
+
// chvt <1
#undef OPTSTR_chvt
#define OPTSTR_chvt "<1"
@@ -2774,9 +2783,9 @@
#undef FLAG_g
#endif
-// source 0<1
+// source <1
#undef OPTSTR_source
-#define OPTSTR_source "0<1"
+#define OPTSTR_source "<1"
#ifdef CLEANUP_source
#undef CLEANUP_source
#undef FOR_source
@@ -3847,6 +3856,13 @@
#define FLAG_m (1<<7)
#endif
+#ifdef FOR_chsh
+#ifndef TT
+#define TT this.chsh
+#endif
+#define FLAG_s (FORCED_FLAG<<0)
+#endif
+
#ifdef FOR_chvt
#ifndef TT
#define TT this.chvt
diff --git a/android/device/generated/globals.h b/android/device/generated/globals.h
index 19c636e6..2211732f 100644
--- a/android/device/generated/globals.h
+++ b/android/device/generated/globals.h
@@ -541,6 +541,12 @@ struct brctl_data {
int sockfd;
};
+// toys/pending/chsh.c
+
+struct chsh_data {
+ char *s;
+};
+
// toys/pending/crond.c
struct crond_data {
@@ -846,43 +852,49 @@ struct sh_data {
// keep ifs here: used to work around compiler limitation in run_command()
char *ifs, *isexec, *wcpat;
unsigned options, jobcnt, LINENO;
- int hfd, pid, bangpid, varslen, cdcount;
+ int hfd, pid, bangpid, varslen, cdcount, srclvl, recursion;
long long SECONDS;
- // global and local variables
- struct sh_vars {
- long flags;
- char *str;
- } *vars;
+// FUNCTION transplant pipelines from place to place?
+// function keyword can have pointer to function struct? Still refcnt?
+// is function body like HERE document? Lifetime rules
- // Parsed functions
+ // Callable functions
struct sh_function {
char *name;
struct sh_pipeline { // pipeline segments: linked list of arg w/metadata
struct sh_pipeline *next, *prev, *end;
- unsigned lineno;
- int count, here, type; // TODO abuse type to replace count during parsing
+ int count, here, type, lineno;
struct sh_arg {
char **v;
int c;
} arg[1];
} *pipeline;
- struct double_list *expect; // should be zero at end of parsing
} *functions;
// runtime function call stack
struct sh_fcall {
- struct sh_fcall *next;
- struct sh_function *func;
+ struct sh_fcall *next, *prev;
+
+ // This dlist in reverse order: TT.ff current function, TT.ff->prev globals
+ struct sh_vars {
+ long flags;
+ char *str;
+ } *vars;
+
+// struct sh_function *func;
struct sh_pipeline *pl;
- int *urd, pout;
+ int varslen;
+ struct sh_arg arg;
+ struct arg_list *delete;
+ long shift;
// Runtime stack of nested if/else/fi and for/do/done contexts.
struct sh_blockstack {
struct sh_blockstack *next;
struct sh_pipeline *start, *middle;
struct sh_process *pp; // list of processes piping in to us
- int run, loop, *urd, pout;
+ int run, loop, *urd, pout, pipe;
struct sh_arg farg; // for/select arg stack, case wildcard deck
struct arg_list *fdelete; // farg's cleanup list
char *fvar; // for/select's iteration variable name
@@ -899,15 +911,6 @@ struct sh_data {
struct sh_arg *raw, arg;
} *pp; // currently running process
- struct sh_callstack {
- struct sh_callstack *next;
- struct sh_function scratch;
- struct sh_arg arg;
- struct arg_list *delete;
- long shift;
- unsigned lineno;
- } *cc;
-
// job list, command line for $*, scratch space for do_wildcard_files()
struct sh_arg jobs, *wcdeck;
};
@@ -1635,6 +1638,7 @@ extern union global_union {
struct bc_data bc;
struct bootchartd_data bootchartd;
struct brctl_data brctl;
+ struct chsh_data chsh;
struct crond_data crond;
struct crontab_data crontab;
struct dd_data dd;
diff --git a/android/device/generated/help.h b/android/device/generated/help.h
index 5467f97e..6a403233 100644
--- a/android/device/generated/help.h
+++ b/android/device/generated/help.h
@@ -362,6 +362,8 @@
#define HELP_shift "usage: shift [N]\n\nSkip N (default 1) positional parameters, moving $1 and friends along the list.\nDoes not affect $0."
+#define HELP_local "usage: local [NAME[=VALUE]...]\n\nCreate a local variable that lasts until return from this function.\nWith no arguments lists local variables in current function context.\nTODO: implement \"declare\" options."
+
#define HELP_jobs "usage: jobs [-lnprs] [%JOB | -x COMMAND...]\n\nList running/stopped background jobs.\n\n-l Include process ID in list\n-n Show only new/changed processes\n-p Show process IDs only\n-r Show running processes\n-s Show stopped processes"
#define HELP_export "usage: export [-n] [NAME[=VALUE]...]\n\nMake variables available to child processes. NAME exports existing local\nvariable(s), NAME=VALUE sets and exports.\n\n-n Unexport. Turn listed variable(s) into local variables.\n\nWith no arguments list exported variables/attributes as \"declare\" statements."
@@ -458,6 +460,8 @@
#define HELP_crond "usage: crond [-fbS] [-l N] [-d N] [-L LOGFILE] [-c DIR]\n\nA daemon to execute scheduled commands.\n\n-b Background (default)\n-c crontab dir\n-d Set log level, log to stderr\n-f Foreground\n-l Set log level. 0 is the most verbose, default 8\n-S Log to syslog (default)\n-L Log to file"
+#define HELP_chsh "usage: chsh [-s SHELL] [USER]\n\nChange user's login shell.\n\n-s Use SHELL instead of prompting\n\nNon-root users can only change their own shell to one listed in /etc/shells."
+
#define HELP_brctl "usage: brctl COMMAND [BRIDGE [INTERFACE]]\n\nManage ethernet bridges\n\nCommands:\nshow Show a list of bridges\naddbr BRIDGE Create BRIDGE\ndelbr BRIDGE Delete BRIDGE\naddif BRIDGE IFACE Add IFACE to BRIDGE\ndelif BRIDGE IFACE Delete IFACE from BRIDGE\nsetageing BRIDGE TIME Set ageing time\nsetfd BRIDGE TIME Set bridge forward delay\nsethello BRIDGE TIME Set hello time\nsetmaxage BRIDGE TIME Set max message age\nsetpathcost BRIDGE PORT COST Set path cost\nsetportprio BRIDGE PORT PRIO Set port priority\nsetbridgeprio BRIDGE PRIO Set bridge priority\nstp BRIDGE [1/yes/on|0/no/off] STP on/off"
#define HELP_bootchartd "usage: bootchartd {start [PROG ARGS]}|stop|init\n\nCreate /var/log/bootlog.tgz with boot chart data\n\nstart: start background logging; with PROG, run PROG,\n then kill logging with USR1\nstop: send USR1 to all bootchartd processes\ninit: start background logging; stop when getty/xdm is seen\n (for init scripts)\n\nUnder PID 1: as init, then exec $bootchart_init, /init, /sbin/init"
diff --git a/android/device/generated/newtoys.h b/android/device/generated/newtoys.h
index 75a5d5ea..8513181b 100644
--- a/android/device/generated/newtoys.h
+++ b/android/device/generated/newtoys.h
@@ -35,6 +35,7 @@ USE_CHMOD(NEWTOY(chmod, "<2?vfR[-vf]", TOYFLAG_BIN))
USE_CHOWN(OLDTOY(chown, chgrp, TOYFLAG_BIN))
USE_CHROOT(NEWTOY(chroot, "^<1", TOYFLAG_USR|TOYFLAG_SBIN|TOYFLAG_ARGFAIL(125)))
USE_CHRT(NEWTOY(chrt, "^mp#<0iRbrfo[!ibrfo]", TOYFLAG_USR|TOYFLAG_BIN))
+USE_CHSH(NEWTOY(chsh, "s:", TOYFLAG_USR|TOYFLAG_BIN|TOYFLAG_STAYROOT))
USE_CHVT(NEWTOY(chvt, "<1", TOYFLAG_USR|TOYFLAG_BIN))
USE_CKSUM(NEWTOY(cksum, "HIPLN", TOYFLAG_BIN))
USE_CLEAR(NEWTOY(clear, NULL, TOYFLAG_USR|TOYFLAG_BIN))
@@ -247,7 +248,7 @@ USE_SKELETON_ALIAS(NEWTOY(skeleton_alias, "b#dq", TOYFLAG_USR|TOYFLAG_BIN))
USE_SLEEP(NEWTOY(sleep, "<1", TOYFLAG_BIN))
USE_SNTP(NEWTOY(sntp, ">1M :m :Sp:t#<0=1>16asdDqr#<4>17=10[!as]", TOYFLAG_USR|TOYFLAG_BIN))
USE_SORT(NEWTOY(sort, USE_SORT_FLOAT("g")"S:T:m" "o:k*t:" "xVbMcszdfirun", TOYFLAG_USR|TOYFLAG_BIN|TOYFLAG_ARGFAIL(2)))
-USE_SH(NEWTOY(source, "0<1", TOYFLAG_NOFORK))
+USE_SH(NEWTOY(source, "<1", TOYFLAG_NOFORK))
USE_SPLIT(NEWTOY(split, ">2a#<1=2>9b#<1l#<1[!bl]", TOYFLAG_USR|TOYFLAG_BIN))
USE_STAT(NEWTOY(stat, "<1c:(format)fLt", TOYFLAG_BIN))
USE_STRINGS(NEWTOY(strings, "t:an#=4<1fo", TOYFLAG_USR|TOYFLAG_BIN))
diff --git a/android/linux/generated/config.h b/android/linux/generated/config.h
index c0a9e81f..79502c00 100644
--- a/android/linux/generated/config.h
+++ b/android/linux/generated/config.h
@@ -110,6 +110,8 @@
#define USE_CHROOT(...)
#define CFG_CHRT 0
#define USE_CHRT(...)
+#define CFG_CHSH 0
+#define USE_CHSH(...)
#define CFG_CHVT 0
#define USE_CHVT(...)
#define CFG_CKSUM 0
diff --git a/android/linux/generated/flags.h b/android/linux/generated/flags.h
index e9bffbf5..84944ce9 100644
--- a/android/linux/generated/flags.h
+++ b/android/linux/generated/flags.h
@@ -314,6 +314,15 @@
#undef FLAG_m
#endif
+// chsh s:
+#undef OPTSTR_chsh
+#define OPTSTR_chsh "s:"
+#ifdef CLEANUP_chsh
+#undef CLEANUP_chsh
+#undef FOR_chsh
+#undef FLAG_s
+#endif
+
// chvt <1
#undef OPTSTR_chvt
#define OPTSTR_chvt "<1"
@@ -2774,9 +2783,9 @@
#undef FLAG_g
#endif
-// source 0<1
+// source <1
#undef OPTSTR_source
-#define OPTSTR_source "0<1"
+#define OPTSTR_source "<1"
#ifdef CLEANUP_source
#undef CLEANUP_source
#undef FOR_source
@@ -3847,6 +3856,13 @@
#define FLAG_m (FORCED_FLAG<<7)
#endif
+#ifdef FOR_chsh
+#ifndef TT
+#define TT this.chsh
+#endif
+#define FLAG_s (FORCED_FLAG<<0)
+#endif
+
#ifdef FOR_chvt
#ifndef TT
#define TT this.chvt
diff --git a/android/linux/generated/globals.h b/android/linux/generated/globals.h
index 19c636e6..2211732f 100644
--- a/android/linux/generated/globals.h
+++ b/android/linux/generated/globals.h
@@ -541,6 +541,12 @@ struct brctl_data {
int sockfd;
};
+// toys/pending/chsh.c
+
+struct chsh_data {
+ char *s;
+};
+
// toys/pending/crond.c
struct crond_data {
@@ -846,43 +852,49 @@ struct sh_data {
// keep ifs here: used to work around compiler limitation in run_command()
char *ifs, *isexec, *wcpat;
unsigned options, jobcnt, LINENO;
- int hfd, pid, bangpid, varslen, cdcount;
+ int hfd, pid, bangpid, varslen, cdcount, srclvl, recursion;
long long SECONDS;
- // global and local variables
- struct sh_vars {
- long flags;
- char *str;
- } *vars;
+// FUNCTION transplant pipelines from place to place?
+// function keyword can have pointer to function struct? Still refcnt?
+// is function body like HERE document? Lifetime rules
- // Parsed functions
+ // Callable functions
struct sh_function {
char *name;
struct sh_pipeline { // pipeline segments: linked list of arg w/metadata
struct sh_pipeline *next, *prev, *end;
- unsigned lineno;
- int count, here, type; // TODO abuse type to replace count during parsing
+ int count, here, type, lineno;
struct sh_arg {
char **v;
int c;
} arg[1];
} *pipeline;
- struct double_list *expect; // should be zero at end of parsing
} *functions;
// runtime function call stack
struct sh_fcall {
- struct sh_fcall *next;
- struct sh_function *func;
+ struct sh_fcall *next, *prev;
+
+ // This dlist in reverse order: TT.ff current function, TT.ff->prev globals
+ struct sh_vars {
+ long flags;
+ char *str;
+ } *vars;
+
+// struct sh_function *func;
struct sh_pipeline *pl;
- int *urd, pout;
+ int varslen;
+ struct sh_arg arg;
+ struct arg_list *delete;
+ long shift;
// Runtime stack of nested if/else/fi and for/do/done contexts.
struct sh_blockstack {
struct sh_blockstack *next;
struct sh_pipeline *start, *middle;
struct sh_process *pp; // list of processes piping in to us
- int run, loop, *urd, pout;
+ int run, loop, *urd, pout, pipe;
struct sh_arg farg; // for/select arg stack, case wildcard deck
struct arg_list *fdelete; // farg's cleanup list
char *fvar; // for/select's iteration variable name
@@ -899,15 +911,6 @@ struct sh_data {
struct sh_arg *raw, arg;
} *pp; // currently running process
- struct sh_callstack {
- struct sh_callstack *next;
- struct sh_function scratch;
- struct sh_arg arg;
- struct arg_list *delete;
- long shift;
- unsigned lineno;
- } *cc;
-
// job list, command line for $*, scratch space for do_wildcard_files()
struct sh_arg jobs, *wcdeck;
};
@@ -1635,6 +1638,7 @@ extern union global_union {
struct bc_data bc;
struct bootchartd_data bootchartd;
struct brctl_data brctl;
+ struct chsh_data chsh;
struct crond_data crond;
struct crontab_data crontab;
struct dd_data dd;
diff --git a/android/linux/generated/help.h b/android/linux/generated/help.h
index b740726f..eebbf545 100644
--- a/android/linux/generated/help.h
+++ b/android/linux/generated/help.h
@@ -364,6 +364,8 @@
#define HELP_shift "usage: shift [N]\n\nSkip N (default 1) positional parameters, moving $1 and friends along the list.\nDoes not affect $0."
+#define HELP_local "usage: local [NAME[=VALUE]...]\n\nCreate a local variable that lasts until return from this function.\nWith no arguments lists local variables in current function context.\nTODO: implement \"declare\" options."
+
#define HELP_jobs "usage: jobs [-lnprs] [%JOB | -x COMMAND...]\n\nList running/stopped background jobs.\n\n-l Include process ID in list\n-n Show only new/changed processes\n-p Show process IDs only\n-r Show running processes\n-s Show stopped processes"
#define HELP_export "usage: export [-n] [NAME[=VALUE]...]\n\nMake variables available to child processes. NAME exports existing local\nvariable(s), NAME=VALUE sets and exports.\n\n-n Unexport. Turn listed variable(s) into local variables.\n\nWith no arguments list exported variables/attributes as \"declare\" statements."
@@ -460,6 +462,8 @@
#define HELP_crond "usage: crond [-fbS] [-l N] [-d N] [-L LOGFILE] [-c DIR]\n\nA daemon to execute scheduled commands.\n\n-b Background (default)\n-c crontab dir\n-d Set log level, log to stderr\n-f Foreground\n-l Set log level. 0 is the most verbose, default 8\n-S Log to syslog (default)\n-L Log to file"
+#define HELP_chsh "usage: chsh [-s SHELL] [USER]\n\nChange user's login shell.\n\n-s Use SHELL instead of prompting\n\nNon-root users can only change their own shell to one listed in /etc/shells."
+
#define HELP_brctl "usage: brctl COMMAND [BRIDGE [INTERFACE]]\n\nManage ethernet bridges\n\nCommands:\nshow Show a list of bridges\naddbr BRIDGE Create BRIDGE\ndelbr BRIDGE Delete BRIDGE\naddif BRIDGE IFACE Add IFACE to BRIDGE\ndelif BRIDGE IFACE Delete IFACE from BRIDGE\nsetageing BRIDGE TIME Set ageing time\nsetfd BRIDGE TIME Set bridge forward delay\nsethello BRIDGE TIME Set hello time\nsetmaxage BRIDGE TIME Set max message age\nsetpathcost BRIDGE PORT COST Set path cost\nsetportprio BRIDGE PORT PRIO Set port priority\nsetbridgeprio BRIDGE PRIO Set bridge priority\nstp BRIDGE [1/yes/on|0/no/off] STP on/off"
#define HELP_bootchartd "usage: bootchartd {start [PROG ARGS]}|stop|init\n\nCreate /var/log/bootlog.tgz with boot chart data\n\nstart: start background logging; with PROG, run PROG,\n then kill logging with USR1\nstop: send USR1 to all bootchartd processes\ninit: start background logging; stop when getty/xdm is seen\n (for init scripts)\n\nUnder PID 1: as init, then exec $bootchart_init, /init, /sbin/init"
diff --git a/android/linux/generated/newtoys.h b/android/linux/generated/newtoys.h
index 75a5d5ea..8513181b 100644
--- a/android/linux/generated/newtoys.h
+++ b/android/linux/generated/newtoys.h
@@ -35,6 +35,7 @@ USE_CHMOD(NEWTOY(chmod, "<2?vfR[-vf]", TOYFLAG_BIN))
USE_CHOWN(OLDTOY(chown, chgrp, TOYFLAG_BIN))
USE_CHROOT(NEWTOY(chroot, "^<1", TOYFLAG_USR|TOYFLAG_SBIN|TOYFLAG_ARGFAIL(125)))
USE_CHRT(NEWTOY(chrt, "^mp#<0iRbrfo[!ibrfo]", TOYFLAG_USR|TOYFLAG_BIN))
+USE_CHSH(NEWTOY(chsh, "s:", TOYFLAG_USR|TOYFLAG_BIN|TOYFLAG_STAYROOT))
USE_CHVT(NEWTOY(chvt, "<1", TOYFLAG_USR|TOYFLAG_BIN))
USE_CKSUM(NEWTOY(cksum, "HIPLN", TOYFLAG_BIN))
USE_CLEAR(NEWTOY(clear, NULL, TOYFLAG_USR|TOYFLAG_BIN))
@@ -247,7 +248,7 @@ USE_SKELETON_ALIAS(NEWTOY(skeleton_alias, "b#dq", TOYFLAG_USR|TOYFLAG_BIN))
USE_SLEEP(NEWTOY(sleep, "<1", TOYFLAG_BIN))
USE_SNTP(NEWTOY(sntp, ">1M :m :Sp:t#<0=1>16asdDqr#<4>17=10[!as]", TOYFLAG_USR|TOYFLAG_BIN))
USE_SORT(NEWTOY(sort, USE_SORT_FLOAT("g")"S:T:m" "o:k*t:" "xVbMcszdfirun", TOYFLAG_USR|TOYFLAG_BIN|TOYFLAG_ARGFAIL(2)))
-USE_SH(NEWTOY(source, "0<1", TOYFLAG_NOFORK))
+USE_SH(NEWTOY(source, "<1", TOYFLAG_NOFORK))
USE_SPLIT(NEWTOY(split, ">2a#<1=2>9b#<1l#<1[!bl]", TOYFLAG_USR|TOYFLAG_BIN))
USE_STAT(NEWTOY(stat, "<1c:(format)fLt", TOYFLAG_BIN))
USE_STRINGS(NEWTOY(strings, "t:an#=4<1fo", TOYFLAG_USR|TOYFLAG_BIN))
diff --git a/android/mac/generated/config.h b/android/mac/generated/config.h
index c7901845..a3c54d84 100644
--- a/android/mac/generated/config.h
+++ b/android/mac/generated/config.h
@@ -110,6 +110,8 @@
#define USE_CHROOT(...)
#define CFG_CHRT 0
#define USE_CHRT(...)
+#define CFG_CHSH 0
+#define USE_CHSH(...)
#define CFG_CHVT 0
#define USE_CHVT(...)
#define CFG_CKSUM 0
diff --git a/android/mac/generated/flags.h b/android/mac/generated/flags.h
index 432f20da..d3a16fe3 100644
--- a/android/mac/generated/flags.h
+++ b/android/mac/generated/flags.h
@@ -314,6 +314,15 @@
#undef FLAG_m
#endif
+// chsh s:
+#undef OPTSTR_chsh
+#define OPTSTR_chsh "s:"
+#ifdef CLEANUP_chsh
+#undef CLEANUP_chsh
+#undef FOR_chsh
+#undef FLAG_s
+#endif
+
// chvt <1
#undef OPTSTR_chvt
#define OPTSTR_chvt "<1"
@@ -2774,9 +2783,9 @@
#undef FLAG_g
#endif
-// source 0<1
+// source <1
#undef OPTSTR_source
-#define OPTSTR_source "0<1"
+#define OPTSTR_source "<1"
#ifdef CLEANUP_source
#undef CLEANUP_source
#undef FOR_source
@@ -3847,6 +3856,13 @@
#define FLAG_m (FORCED_FLAG<<7)
#endif
+#ifdef FOR_chsh
+#ifndef TT
+#define TT this.chsh
+#endif
+#define FLAG_s (FORCED_FLAG<<0)
+#endif
+
#ifdef FOR_chvt
#ifndef TT
#define TT this.chvt
diff --git a/android/mac/generated/globals.h b/android/mac/generated/globals.h
index 19c636e6..2211732f 100644
--- a/android/mac/generated/globals.h
+++ b/android/mac/generated/globals.h
@@ -541,6 +541,12 @@ struct brctl_data {
int sockfd;
};
+// toys/pending/chsh.c
+
+struct chsh_data {
+ char *s;
+};
+
// toys/pending/crond.c
struct crond_data {
@@ -846,43 +852,49 @@ struct sh_data {
// keep ifs here: used to work around compiler limitation in run_command()
char *ifs, *isexec, *wcpat;
unsigned options, jobcnt, LINENO;
- int hfd, pid, bangpid, varslen, cdcount;
+ int hfd, pid, bangpid, varslen, cdcount, srclvl, recursion;
long long SECONDS;
- // global and local variables
- struct sh_vars {
- long flags;
- char *str;
- } *vars;
+// FUNCTION transplant pipelines from place to place?
+// function keyword can have pointer to function struct? Still refcnt?
+// is function body like HERE document? Lifetime rules
- // Parsed functions
+ // Callable functions
struct sh_function {
char *name;
struct sh_pipeline { // pipeline segments: linked list of arg w/metadata
struct sh_pipeline *next, *prev, *end;
- unsigned lineno;
- int count, here, type; // TODO abuse type to replace count during parsing
+ int count, here, type, lineno;
struct sh_arg {
char **v;
int c;
} arg[1];
} *pipeline;
- struct double_list *expect; // should be zero at end of parsing
} *functions;
// runtime function call stack
struct sh_fcall {
- struct sh_fcall *next;
- struct sh_function *func;
+ struct sh_fcall *next, *prev;
+
+ // This dlist in reverse order: TT.ff current function, TT.ff->prev globals
+ struct sh_vars {
+ long flags;
+ char *str;
+ } *vars;
+
+// struct sh_function *func;
struct sh_pipeline *pl;
- int *urd, pout;
+ int varslen;
+ struct sh_arg arg;
+ struct arg_list *delete;
+ long shift;
// Runtime stack of nested if/else/fi and for/do/done contexts.
struct sh_blockstack {
struct sh_blockstack *next;
struct sh_pipeline *start, *middle;
struct sh_process *pp; // list of processes piping in to us
- int run, loop, *urd, pout;
+ int run, loop, *urd, pout, pipe;
struct sh_arg farg; // for/select arg stack, case wildcard deck
struct arg_list *fdelete; // farg's cleanup list
char *fvar; // for/select's iteration variable name
@@ -899,15 +911,6 @@ struct sh_data {
struct sh_arg *raw, arg;
} *pp; // currently running process
- struct sh_callstack {
- struct sh_callstack *next;
- struct sh_function scratch;
- struct sh_arg arg;
- struct arg_list *delete;
- long shift;
- unsigned lineno;
- } *cc;
-
// job list, command line for $*, scratch space for do_wildcard_files()
struct sh_arg jobs, *wcdeck;
};
@@ -1635,6 +1638,7 @@ extern union global_union {
struct bc_data bc;
struct bootchartd_data bootchartd;
struct brctl_data brctl;
+ struct chsh_data chsh;
struct crond_data crond;
struct crontab_data crontab;
struct dd_data dd;
diff --git a/android/mac/generated/help.h b/android/mac/generated/help.h
index b740726f..eebbf545 100644
--- a/android/mac/generated/help.h
+++ b/android/mac/generated/help.h
@@ -364,6 +364,8 @@
#define HELP_shift "usage: shift [N]\n\nSkip N (default 1) positional parameters, moving $1 and friends along the list.\nDoes not affect $0."
+#define HELP_local "usage: local [NAME[=VALUE]...]\n\nCreate a local variable that lasts until return from this function.\nWith no arguments lists local variables in current function context.\nTODO: implement \"declare\" options."
+
#define HELP_jobs "usage: jobs [-lnprs] [%JOB | -x COMMAND...]\n\nList running/stopped background jobs.\n\n-l Include process ID in list\n-n Show only new/changed processes\n-p Show process IDs only\n-r Show running processes\n-s Show stopped processes"
#define HELP_export "usage: export [-n] [NAME[=VALUE]...]\n\nMake variables available to child processes. NAME exports existing local\nvariable(s), NAME=VALUE sets and exports.\n\n-n Unexport. Turn listed variable(s) into local variables.\n\nWith no arguments list exported variables/attributes as \"declare\" statements."
@@ -460,6 +462,8 @@
#define HELP_crond "usage: crond [-fbS] [-l N] [-d N] [-L LOGFILE] [-c DIR]\n\nA daemon to execute scheduled commands.\n\n-b Background (default)\n-c crontab dir\n-d Set log level, log to stderr\n-f Foreground\n-l Set log level. 0 is the most verbose, default 8\n-S Log to syslog (default)\n-L Log to file"
+#define HELP_chsh "usage: chsh [-s SHELL] [USER]\n\nChange user's login shell.\n\n-s Use SHELL instead of prompting\n\nNon-root users can only change their own shell to one listed in /etc/shells."
+
#define HELP_brctl "usage: brctl COMMAND [BRIDGE [INTERFACE]]\n\nManage ethernet bridges\n\nCommands:\nshow Show a list of bridges\naddbr BRIDGE Create BRIDGE\ndelbr BRIDGE Delete BRIDGE\naddif BRIDGE IFACE Add IFACE to BRIDGE\ndelif BRIDGE IFACE Delete IFACE from BRIDGE\nsetageing BRIDGE TIME Set ageing time\nsetfd BRIDGE TIME Set bridge forward delay\nsethello BRIDGE TIME Set hello time\nsetmaxage BRIDGE TIME Set max message age\nsetpathcost BRIDGE PORT COST Set path cost\nsetportprio BRIDGE PORT PRIO Set port priority\nsetbridgeprio BRIDGE PRIO Set bridge priority\nstp BRIDGE [1/yes/on|0/no/off] STP on/off"
#define HELP_bootchartd "usage: bootchartd {start [PROG ARGS]}|stop|init\n\nCreate /var/log/bootlog.tgz with boot chart data\n\nstart: start background logging; with PROG, run PROG,\n then kill logging with USR1\nstop: send USR1 to all bootchartd processes\ninit: start background logging; stop when getty/xdm is seen\n (for init scripts)\n\nUnder PID 1: as init, then exec $bootchart_init, /init, /sbin/init"
diff --git a/android/mac/generated/newtoys.h b/android/mac/generated/newtoys.h
index 75a5d5ea..8513181b 100644
--- a/android/mac/generated/newtoys.h
+++ b/android/mac/generated/newtoys.h
@@ -35,6 +35,7 @@ USE_CHMOD(NEWTOY(chmod, "<2?vfR[-vf]", TOYFLAG_BIN))
USE_CHOWN(OLDTOY(chown, chgrp, TOYFLAG_BIN))
USE_CHROOT(NEWTOY(chroot, "^<1", TOYFLAG_USR|TOYFLAG_SBIN|TOYFLAG_ARGFAIL(125)))
USE_CHRT(NEWTOY(chrt, "^mp#<0iRbrfo[!ibrfo]", TOYFLAG_USR|TOYFLAG_BIN))
+USE_CHSH(NEWTOY(chsh, "s:", TOYFLAG_USR|TOYFLAG_BIN|TOYFLAG_STAYROOT))
USE_CHVT(NEWTOY(chvt, "<1", TOYFLAG_USR|TOYFLAG_BIN))
USE_CKSUM(NEWTOY(cksum, "HIPLN", TOYFLAG_BIN))
USE_CLEAR(NEWTOY(clear, NULL, TOYFLAG_USR|TOYFLAG_BIN))
@@ -247,7 +248,7 @@ USE_SKELETON_ALIAS(NEWTOY(skeleton_alias, "b#dq", TOYFLAG_USR|TOYFLAG_BIN))
USE_SLEEP(NEWTOY(sleep, "<1", TOYFLAG_BIN))
USE_SNTP(NEWTOY(sntp, ">1M :m :Sp:t#<0=1>16asdDqr#<4>17=10[!as]", TOYFLAG_USR|TOYFLAG_BIN))
USE_SORT(NEWTOY(sort, USE_SORT_FLOAT("g")"S:T:m" "o:k*t:" "xVbMcszdfirun", TOYFLAG_USR|TOYFLAG_BIN|TOYFLAG_ARGFAIL(2)))
-USE_SH(NEWTOY(source, "0<1", TOYFLAG_NOFORK))
+USE_SH(NEWTOY(source, "<1", TOYFLAG_NOFORK))
USE_SPLIT(NEWTOY(split, ">2a#<1=2>9b#<1l#<1[!bl]", TOYFLAG_USR|TOYFLAG_BIN))
USE_STAT(NEWTOY(stat, "<1c:(format)fLt", TOYFLAG_BIN))
USE_STRINGS(NEWTOY(strings, "t:an#=4<1fo", TOYFLAG_USR|TOYFLAG_BIN))