diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-01-08 18:40:41 +0100 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-01-08 18:40:41 +0100 |
| commit | 6ec76d8719279dbda0b2a98163625b6f2ea013ff (patch) | |
| tree | 849a6d507a40a8f7e606364ca9d23245d286e572 /shell | |
| parent | d5933b112537f9cb9d6ebb0109a0a38cea71fa63 (diff) | |
| download | busybox-w32-6ec76d8719279dbda0b2a98163625b6f2ea013ff.tar.gz busybox-w32-6ec76d8719279dbda0b2a98163625b6f2ea013ff.tar.bz2 busybox-w32-6ec76d8719279dbda0b2a98163625b6f2ea013ff.zip | |
hush: make export builtin optional
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
| -rw-r--r-- | shell/hush.c | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/shell/hush.c b/shell/hush.c index a713a9680..153867614 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
| @@ -187,13 +187,6 @@ | |||
| 187 | //config: Enable pseudorandom generator and dynamic variable "$RANDOM". | 187 | //config: Enable pseudorandom generator and dynamic variable "$RANDOM". |
| 188 | //config: Each read of "$RANDOM" will generate a new pseudorandom value. | 188 | //config: Each read of "$RANDOM" will generate a new pseudorandom value. |
| 189 | //config: | 189 | //config: |
| 190 | //config:config HUSH_EXPORT_N | ||
| 191 | //config: bool "Support 'export -n' option" | ||
| 192 | //config: default y | ||
| 193 | //config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH | ||
| 194 | //config: help | ||
| 195 | //config: export -n unexports variables. It is a bash extension. | ||
| 196 | //config: | ||
| 197 | //config:config HUSH_MODE_X | 190 | //config:config HUSH_MODE_X |
| 198 | //config: bool "Support 'hush -x' option and 'set -x' command" | 191 | //config: bool "Support 'hush -x' option and 'set -x' command" |
| 199 | //config: default y | 192 | //config: default y |
| @@ -202,6 +195,20 @@ | |||
| 202 | //config: This instructs hush to print commands before execution. | 195 | //config: This instructs hush to print commands before execution. |
| 203 | //config: Adds ~300 bytes. | 196 | //config: Adds ~300 bytes. |
| 204 | //config: | 197 | //config: |
| 198 | //config:config HUSH_EXPORT | ||
| 199 | //config: bool "export builtin" | ||
| 200 | //config: default y | ||
| 201 | //config: depends on HUSH || SH_IS_HUSH || BASH_IS_HUSH | ||
| 202 | //config: help | ||
| 203 | //config: Enable export builtin in hush. | ||
| 204 | //config: | ||
| 205 | //config:config HUSH_EXPORT_N | ||
| 206 | //config: bool "Support 'export -n' option" | ||
| 207 | //config: default y | ||
| 208 | //config: depends on HUSH_EXPORT | ||
| 209 | //config: help | ||
| 210 | //config: export -n unexports variables. It is a bash extension. | ||
| 211 | //config: | ||
| 205 | //config:config HUSH_HELP | 212 | //config:config HUSH_HELP |
| 206 | //config: bool "help builtin" | 213 | //config: bool "help builtin" |
| 207 | //config: default y | 214 | //config: default y |
| @@ -917,7 +924,9 @@ static int builtin_echo(char **argv) FAST_FUNC; | |||
| 917 | static int builtin_eval(char **argv) FAST_FUNC; | 924 | static int builtin_eval(char **argv) FAST_FUNC; |
| 918 | static int builtin_exec(char **argv) FAST_FUNC; | 925 | static int builtin_exec(char **argv) FAST_FUNC; |
| 919 | static int builtin_exit(char **argv) FAST_FUNC; | 926 | static int builtin_exit(char **argv) FAST_FUNC; |
| 927 | #if ENABLE_HUSH_EXPORT | ||
| 920 | static int builtin_export(char **argv) FAST_FUNC; | 928 | static int builtin_export(char **argv) FAST_FUNC; |
| 929 | #endif | ||
| 921 | #if ENABLE_HUSH_JOB | 930 | #if ENABLE_HUSH_JOB |
| 922 | static int builtin_fg_bg(char **argv) FAST_FUNC; | 931 | static int builtin_fg_bg(char **argv) FAST_FUNC; |
| 923 | static int builtin_jobs(char **argv) FAST_FUNC; | 932 | static int builtin_jobs(char **argv) FAST_FUNC; |
| @@ -1007,7 +1016,9 @@ static const struct built_in_command bltins1[] = { | |||
| 1007 | BLTIN("eval" , builtin_eval , "Construct and run shell command"), | 1016 | BLTIN("eval" , builtin_eval , "Construct and run shell command"), |
| 1008 | BLTIN("exec" , builtin_exec , "Execute command, don't return to shell"), | 1017 | BLTIN("exec" , builtin_exec , "Execute command, don't return to shell"), |
| 1009 | BLTIN("exit" , builtin_exit , "Exit"), | 1018 | BLTIN("exit" , builtin_exit , "Exit"), |
| 1019 | #if ENABLE_HUSH_EXPORT | ||
| 1010 | BLTIN("export" , builtin_export , "Set environment variables"), | 1020 | BLTIN("export" , builtin_export , "Set environment variables"), |
| 1021 | #endif | ||
| 1011 | #if ENABLE_HUSH_JOB | 1022 | #if ENABLE_HUSH_JOB |
| 1012 | BLTIN("fg" , builtin_fg_bg , "Bring job into the foreground"), | 1023 | BLTIN("fg" , builtin_fg_bg , "Bring job into the foreground"), |
| 1013 | #endif | 1024 | #endif |
| @@ -8935,10 +8946,11 @@ static void print_escaped(const char *s) | |||
| 8935 | } while (*s); | 8946 | } while (*s); |
| 8936 | } | 8947 | } |
| 8937 | 8948 | ||
| 8938 | #if !ENABLE_HUSH_LOCAL | 8949 | #if ENABLE_HUSH_EXPORT || ENABLE_HUSH_LOCAL |
| 8950 | # if !ENABLE_HUSH_LOCAL | ||
| 8939 | #define helper_export_local(argv, exp, lvl) \ | 8951 | #define helper_export_local(argv, exp, lvl) \ |
| 8940 | helper_export_local(argv, exp) | 8952 | helper_export_local(argv, exp) |
| 8941 | #endif | 8953 | # endif |
| 8942 | static void helper_export_local(char **argv, int exp, int lvl) | 8954 | static void helper_export_local(char **argv, int exp, int lvl) |
| 8943 | { | 8955 | { |
| 8944 | do { | 8956 | do { |
| @@ -8971,14 +8983,14 @@ static void helper_export_local(char **argv, int exp, int lvl) | |||
| 8971 | continue; | 8983 | continue; |
| 8972 | } | 8984 | } |
| 8973 | } | 8985 | } |
| 8974 | #if ENABLE_HUSH_LOCAL | 8986 | # if ENABLE_HUSH_LOCAL |
| 8975 | if (exp == 0 /* local? */ | 8987 | if (exp == 0 /* local? */ |
| 8976 | && var && var->func_nest_level == lvl | 8988 | && var && var->func_nest_level == lvl |
| 8977 | ) { | 8989 | ) { |
| 8978 | /* "local x=abc; ...; local x" - ignore second local decl */ | 8990 | /* "local x=abc; ...; local x" - ignore second local decl */ |
| 8979 | continue; | 8991 | continue; |
| 8980 | } | 8992 | } |
| 8981 | #endif | 8993 | # endif |
| 8982 | /* Exporting non-existing variable. | 8994 | /* Exporting non-existing variable. |
| 8983 | * bash does not put it in environment, | 8995 | * bash does not put it in environment, |
| 8984 | * but remembers that it is exported, | 8996 | * but remembers that it is exported, |
| @@ -8994,7 +9006,9 @@ static void helper_export_local(char **argv, int exp, int lvl) | |||
| 8994 | set_local_var(name, /*exp:*/ exp, /*lvl:*/ lvl, /*ro:*/ 0); | 9006 | set_local_var(name, /*exp:*/ exp, /*lvl:*/ lvl, /*ro:*/ 0); |
| 8995 | } while (*++argv); | 9007 | } while (*++argv); |
| 8996 | } | 9008 | } |
| 9009 | #endif | ||
| 8997 | 9010 | ||
| 9011 | #if ENABLE_HUSH_EXPORT | ||
| 8998 | static int FAST_FUNC builtin_export(char **argv) | 9012 | static int FAST_FUNC builtin_export(char **argv) |
| 8999 | { | 9013 | { |
| 9000 | unsigned opt_unexport; | 9014 | unsigned opt_unexport; |
| @@ -9040,6 +9054,7 @@ static int FAST_FUNC builtin_export(char **argv) | |||
| 9040 | 9054 | ||
| 9041 | return EXIT_SUCCESS; | 9055 | return EXIT_SUCCESS; |
| 9042 | } | 9056 | } |
| 9057 | #endif | ||
| 9043 | 9058 | ||
| 9044 | #if ENABLE_HUSH_LOCAL | 9059 | #if ENABLE_HUSH_LOCAL |
| 9045 | static int FAST_FUNC builtin_local(char **argv) | 9060 | static int FAST_FUNC builtin_local(char **argv) |
