diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2010-09-14 12:47:25 +1000 |
---|---|---|
committer | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2010-09-14 12:47:25 +1000 |
commit | 9df56f96fd9a213189ca94c1fccfc3c42bd9c16a (patch) | |
tree | db1db005b59e2b78d5daf9527fa8fc604e07e8c4 /shell | |
parent | 30c62e541a1484fedc3d689d62f96d246a28b147 (diff) | |
parent | 5f3303712ef483d270097cae4ba0a559b1056121 (diff) | |
download | busybox-w32-9df56f96fd9a213189ca94c1fccfc3c42bd9c16a.tar.gz busybox-w32-9df56f96fd9a213189ca94c1fccfc3c42bd9c16a.tar.bz2 busybox-w32-9df56f96fd9a213189ca94c1fccfc3c42bd9c16a.zip |
Merge branch 'origin/master' (early part)
Diffstat (limited to 'shell')
-rw-r--r-- | shell/Config.src (renamed from shell/Config.in) | 48 | ||||
-rw-r--r-- | shell/Kbuild.src (renamed from shell/Kbuild) | 0 | ||||
-rw-r--r-- | shell/ash.c | 32 |
3 files changed, 40 insertions, 40 deletions
diff --git a/shell/Config.in b/shell/Config.src index 286a3415e..234d05367 100644 --- a/shell/Config.in +++ b/shell/Config.src | |||
@@ -7,7 +7,7 @@ menu "Shells" | |||
7 | 7 | ||
8 | choice | 8 | choice |
9 | prompt "Choose which shell is aliased to 'sh' name" | 9 | prompt "Choose which shell is aliased to 'sh' name" |
10 | default FEATURE_SH_IS_NONE | 10 | default FEATURE_SH_IS_ASH |
11 | help | 11 | help |
12 | Choose which shell you want to be executed by 'sh' alias. | 12 | Choose which shell you want to be executed by 'sh' alias. |
13 | The ash shell is the most bash compatible and full featured one. | 13 | The ash shell is the most bash compatible and full featured one. |
@@ -59,7 +59,7 @@ endchoice | |||
59 | 59 | ||
60 | config ASH | 60 | config ASH |
61 | bool "ash" | 61 | bool "ash" |
62 | default n | 62 | default y |
63 | depends on !NOMMU | 63 | depends on !NOMMU |
64 | help | 64 | help |
65 | Tha 'ash' shell adds about 60k in the default configuration and is | 65 | Tha 'ash' shell adds about 60k in the default configuration and is |
@@ -91,7 +91,7 @@ config ASH_ALIAS | |||
91 | 91 | ||
92 | config ASH_GETOPTS | 92 | config ASH_GETOPTS |
93 | bool "Builtin getopt to parse positional parameters" | 93 | bool "Builtin getopt to parse positional parameters" |
94 | default n | 94 | default y |
95 | depends on ASH | 95 | depends on ASH |
96 | help | 96 | help |
97 | Enable getopts builtin in the ash shell. | 97 | Enable getopts builtin in the ash shell. |
@@ -119,7 +119,7 @@ config ASH_BUILTIN_TEST | |||
119 | 119 | ||
120 | config ASH_CMDCMD | 120 | config ASH_CMDCMD |
121 | bool "'command' command to override shell builtins" | 121 | bool "'command' command to override shell builtins" |
122 | default n | 122 | default y |
123 | depends on ASH | 123 | depends on ASH |
124 | help | 124 | help |
125 | Enable support for the ash 'command' builtin, which allows | 125 | Enable support for the ash 'command' builtin, which allows |
@@ -128,7 +128,7 @@ config ASH_CMDCMD | |||
128 | 128 | ||
129 | config ASH_MAIL | 129 | config ASH_MAIL |
130 | bool "Check for new mail on interactive shells" | 130 | bool "Check for new mail on interactive shells" |
131 | default y | 131 | default n |
132 | depends on ASH | 132 | depends on ASH |
133 | help | 133 | help |
134 | Enable "check for new mail" in the ash shell. | 134 | Enable "check for new mail" in the ash shell. |
@@ -142,7 +142,7 @@ config ASH_OPTIMIZE_FOR_SIZE | |||
142 | 142 | ||
143 | config ASH_RANDOM_SUPPORT | 143 | config ASH_RANDOM_SUPPORT |
144 | bool "Pseudorandom generator and $RANDOM variable" | 144 | bool "Pseudorandom generator and $RANDOM variable" |
145 | default n | 145 | default y |
146 | depends on ASH | 146 | depends on ASH |
147 | help | 147 | help |
148 | Enable pseudorandom generator and dynamic variable "$RANDOM". | 148 | Enable pseudorandom generator and dynamic variable "$RANDOM". |
@@ -153,7 +153,7 @@ config ASH_RANDOM_SUPPORT | |||
153 | 153 | ||
154 | config ASH_EXPAND_PRMT | 154 | config ASH_EXPAND_PRMT |
155 | bool "Expand prompt string" | 155 | bool "Expand prompt string" |
156 | default n | 156 | default y |
157 | depends on ASH | 157 | depends on ASH |
158 | help | 158 | help |
159 | "PS#" may contain volatile content, such as backquote commands. | 159 | "PS#" may contain volatile content, such as backquote commands. |
@@ -162,7 +162,7 @@ config ASH_EXPAND_PRMT | |||
162 | 162 | ||
163 | config HUSH | 163 | config HUSH |
164 | bool "hush" | 164 | bool "hush" |
165 | default n | 165 | default y |
166 | help | 166 | help |
167 | hush is a small shell (22k). It handles the normal flow control | 167 | hush is a small shell (22k). It handles the normal flow control |
168 | constructs such as if/then/elif/else/fi, for/in/do/done, while loops, | 168 | constructs such as if/then/elif/else/fi, for/in/do/done, while loops, |
@@ -183,7 +183,7 @@ config HUSH_BASH_COMPAT | |||
183 | 183 | ||
184 | config HUSH_HELP | 184 | config HUSH_HELP |
185 | bool "help builtin" | 185 | bool "help builtin" |
186 | default n | 186 | default y |
187 | depends on HUSH | 187 | depends on HUSH |
188 | help | 188 | help |
189 | Enable help builtin in hush. Code size + ~1 kbyte. | 189 | Enable help builtin in hush. Code size + ~1 kbyte. |
@@ -200,7 +200,7 @@ config HUSH_INTERACTIVE | |||
200 | 200 | ||
201 | config HUSH_JOB | 201 | config HUSH_JOB |
202 | bool "Job control" | 202 | bool "Job control" |
203 | default n | 203 | default y |
204 | depends on HUSH_INTERACTIVE | 204 | depends on HUSH_INTERACTIVE |
205 | help | 205 | help |
206 | Enable job control: Ctrl-Z backgrounds, Ctrl-C interrupts current | 206 | Enable job control: Ctrl-Z backgrounds, Ctrl-C interrupts current |
@@ -211,56 +211,56 @@ config HUSH_JOB | |||
211 | 211 | ||
212 | config HUSH_TICK | 212 | config HUSH_TICK |
213 | bool "Process substitution" | 213 | bool "Process substitution" |
214 | default n | 214 | default y |
215 | depends on HUSH | 215 | depends on HUSH |
216 | help | 216 | help |
217 | Enable process substitution `command` and $(command) in hush. | 217 | Enable process substitution `command` and $(command) in hush. |
218 | 218 | ||
219 | config HUSH_IF | 219 | config HUSH_IF |
220 | bool "Support if/then/elif/else/fi" | 220 | bool "Support if/then/elif/else/fi" |
221 | default n | 221 | default y |
222 | depends on HUSH | 222 | depends on HUSH |
223 | help | 223 | help |
224 | Enable if/then/elif/else/fi in hush. | 224 | Enable if/then/elif/else/fi in hush. |
225 | 225 | ||
226 | config HUSH_LOOPS | 226 | config HUSH_LOOPS |
227 | bool "Support for, while and until loops" | 227 | bool "Support for, while and until loops" |
228 | default n | 228 | default y |
229 | depends on HUSH | 229 | depends on HUSH |
230 | help | 230 | help |
231 | Enable for, while and until loops in hush. | 231 | Enable for, while and until loops in hush. |
232 | 232 | ||
233 | config HUSH_CASE | 233 | config HUSH_CASE |
234 | bool "Support case ... esac statement" | 234 | bool "Support case ... esac statement" |
235 | default n | 235 | default y |
236 | depends on HUSH | 236 | depends on HUSH |
237 | help | 237 | help |
238 | Enable case ... esac statement in hush. +400 bytes. | 238 | Enable case ... esac statement in hush. +400 bytes. |
239 | 239 | ||
240 | config HUSH_FUNCTIONS | 240 | config HUSH_FUNCTIONS |
241 | bool "Support funcname() { commands; } syntax" | 241 | bool "Support funcname() { commands; } syntax" |
242 | default n | 242 | default y |
243 | depends on HUSH | 243 | depends on HUSH |
244 | help | 244 | help |
245 | Enable support for shell functions in hush. +800 bytes. | 245 | Enable support for shell functions in hush. +800 bytes. |
246 | 246 | ||
247 | config HUSH_LOCAL | 247 | config HUSH_LOCAL |
248 | bool "Support local builtin" | 248 | bool "Support local builtin" |
249 | default n | 249 | default y |
250 | depends on HUSH_FUNCTIONS | 250 | depends on HUSH_FUNCTIONS |
251 | help | 251 | help |
252 | Enable support for local variables in functions. | 252 | Enable support for local variables in functions. |
253 | 253 | ||
254 | config HUSH_EXPORT_N | 254 | config HUSH_EXPORT_N |
255 | bool "Support export '-n' option" | 255 | bool "Support export '-n' option" |
256 | default n | 256 | default y |
257 | depends on HUSH | 257 | depends on HUSH |
258 | help | 258 | help |
259 | Enable support for export '-n' option in hush. It is a bash extension. | 259 | Enable support for export '-n' option in hush. It is a bash extension. |
260 | 260 | ||
261 | config HUSH_RANDOM_SUPPORT | 261 | config HUSH_RANDOM_SUPPORT |
262 | bool "Pseudorandom generator and $RANDOM variable" | 262 | bool "Pseudorandom generator and $RANDOM variable" |
263 | default n | 263 | default y |
264 | depends on HUSH | 264 | depends on HUSH |
265 | help | 265 | help |
266 | Enable pseudorandom generator and dynamic variable "$RANDOM". | 266 | Enable pseudorandom generator and dynamic variable "$RANDOM". |
@@ -298,7 +298,7 @@ config SH_MATH_SUPPORT | |||
298 | 298 | ||
299 | config SH_MATH_SUPPORT_64 | 299 | config SH_MATH_SUPPORT_64 |
300 | bool "Extend POSIX math support to 64 bit" | 300 | bool "Extend POSIX math support to 64 bit" |
301 | default n | 301 | default y |
302 | depends on SH_MATH_SUPPORT | 302 | depends on SH_MATH_SUPPORT |
303 | help | 303 | help |
304 | Enable 64-bit math support in the shell. This will make the shell | 304 | Enable 64-bit math support in the shell. This will make the shell |
@@ -307,15 +307,15 @@ config SH_MATH_SUPPORT_64 | |||
307 | 307 | ||
308 | config FEATURE_SH_EXTRA_QUIET | 308 | config FEATURE_SH_EXTRA_QUIET |
309 | bool "Hide message on interactive shell startup" | 309 | bool "Hide message on interactive shell startup" |
310 | default n | 310 | default y |
311 | depends on MSH || LASH || HUSH || ASH | 311 | depends on HUSH || ASH |
312 | help | 312 | help |
313 | Remove the busybox introduction when starting a shell. | 313 | Remove the busybox introduction when starting a shell. |
314 | 314 | ||
315 | config FEATURE_SH_STANDALONE | 315 | config FEATURE_SH_STANDALONE |
316 | bool "Standalone shell" | 316 | bool "Standalone shell" |
317 | default n | 317 | default n |
318 | depends on (MSH || LASH || HUSH || ASH) && FEATURE_PREFER_APPLETS | 318 | depends on (HUSH || ASH) && FEATURE_PREFER_APPLETS |
319 | help | 319 | help |
320 | This option causes busybox shells to use busybox applets | 320 | This option causes busybox shells to use busybox applets |
321 | in preference to executables in the PATH whenever possible. For | 321 | in preference to executables in the PATH whenever possible. For |
@@ -348,7 +348,7 @@ config FEATURE_SH_STANDALONE | |||
348 | config FEATURE_SH_NOFORK | 348 | config FEATURE_SH_NOFORK |
349 | bool "Run 'nofork' applets directly" | 349 | bool "Run 'nofork' applets directly" |
350 | default n | 350 | default n |
351 | depends on (MSH || LASH || HUSH || ASH) && FEATURE_PREFER_APPLETS | 351 | depends on (HUSH || ASH) && FEATURE_PREFER_APPLETS |
352 | help | 352 | help |
353 | This option causes busybox shells [currently only ash] | 353 | This option causes busybox shells [currently only ash] |
354 | to not execute typical fork/exec/wait sequence, but call <applet>_main | 354 | to not execute typical fork/exec/wait sequence, but call <applet>_main |
@@ -364,7 +364,7 @@ config FEATURE_SH_NOFORK | |||
364 | 364 | ||
365 | config CTTYHACK | 365 | config CTTYHACK |
366 | bool "cttyhack" | 366 | bool "cttyhack" |
367 | default n | 367 | default y |
368 | help | 368 | help |
369 | One common problem reported on the mailing list is "can't access tty; | 369 | One common problem reported on the mailing list is "can't access tty; |
370 | job control turned off" error message which typically appears when | 370 | job control turned off" error message which typically appears when |
diff --git a/shell/Kbuild b/shell/Kbuild.src index 8bdb68b11..8bdb68b11 100644 --- a/shell/Kbuild +++ b/shell/Kbuild.src | |||
diff --git a/shell/ash.c b/shell/ash.c index dcaac1fd8..89e70c1ee 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -1093,7 +1093,7 @@ struct strpush { | |||
1093 | struct parsefile { | 1093 | struct parsefile { |
1094 | struct parsefile *prev; /* preceding file on stack */ | 1094 | struct parsefile *prev; /* preceding file on stack */ |
1095 | int linno; /* current line */ | 1095 | int linno; /* current line */ |
1096 | int fd; /* file descriptor (or -1 if string) */ | 1096 | int pf_fd; /* file descriptor (or -1 if string) */ |
1097 | int left_in_line; /* number of chars left in this line */ | 1097 | int left_in_line; /* number of chars left in this line */ |
1098 | int left_in_buffer; /* number of chars left in this buffer past the line */ | 1098 | int left_in_buffer; /* number of chars left in this buffer past the line */ |
1099 | char *next_to_pgetc; /* next char in buffer */ | 1099 | char *next_to_pgetc; /* next char in buffer */ |
@@ -1119,7 +1119,7 @@ ash_vmsg(const char *msg, va_list ap) | |||
1119 | if (commandname) { | 1119 | if (commandname) { |
1120 | if (strcmp(arg0, commandname)) | 1120 | if (strcmp(arg0, commandname)) |
1121 | fprintf(stderr, "%s: ", commandname); | 1121 | fprintf(stderr, "%s: ", commandname); |
1122 | if (!iflag || g_parsefile->fd > 0) | 1122 | if (!iflag || g_parsefile->pf_fd > 0) |
1123 | fprintf(stderr, "line %d: ", startlinno); | 1123 | fprintf(stderr, "line %d: ", startlinno); |
1124 | } | 1124 | } |
1125 | vfprintf(stderr, msg, ap); | 1125 | vfprintf(stderr, msg, ap); |
@@ -5356,15 +5356,15 @@ static int is_hidden_fd(struct redirtab *rp, int fd) | |||
5356 | /* Check open scripts' fds */ | 5356 | /* Check open scripts' fds */ |
5357 | pf = g_parsefile; | 5357 | pf = g_parsefile; |
5358 | while (pf) { | 5358 | while (pf) { |
5359 | /* We skip fd == 0 case because of the following case: | 5359 | /* We skip pf_fd == 0 case because of the following case: |
5360 | * $ ash # running ash interactively | 5360 | * $ ash # running ash interactively |
5361 | * $ . ./script.sh | 5361 | * $ . ./script.sh |
5362 | * and in script.sh: "exec 9>&0". | 5362 | * and in script.sh: "exec 9>&0". |
5363 | * Even though top-level fd _is_ 0, | 5363 | * Even though top-level pf_fd _is_ 0, |
5364 | * it's still ok to use it: "read" builtin uses it, | 5364 | * it's still ok to use it: "read" builtin uses it, |
5365 | * why should we cripple "exec" builtin? | 5365 | * why should we cripple "exec" builtin? |
5366 | */ | 5366 | */ |
5367 | if (pf->fd > 0 && fd == pf->fd) { | 5367 | if (pf->pf_fd > 0 && fd == pf->pf_fd) { |
5368 | return 1; | 5368 | return 1; |
5369 | } | 5369 | } |
5370 | pf = pf->prev; | 5370 | pf = pf->prev; |
@@ -9921,8 +9921,8 @@ preadfd(void) | |||
9921 | g_parsefile->next_to_pgetc = buf; | 9921 | g_parsefile->next_to_pgetc = buf; |
9922 | #if ENABLE_FEATURE_EDITING | 9922 | #if ENABLE_FEATURE_EDITING |
9923 | retry: | 9923 | retry: |
9924 | if (!iflag || g_parsefile->fd != STDIN_FILENO) | 9924 | if (!iflag || g_parsefile->pf_fd != STDIN_FILENO) |
9925 | nr = nonblock_safe_read(g_parsefile->fd, buf, IBUFSIZ - 1); | 9925 | nr = nonblock_safe_read(g_parsefile->pf_fd, buf, IBUFSIZ - 1); |
9926 | else { | 9926 | else { |
9927 | #if ENABLE_FEATURE_TAB_COMPLETION | 9927 | #if ENABLE_FEATURE_TAB_COMPLETION |
9928 | line_input_state->path_lookup = pathval(); | 9928 | line_input_state->path_lookup = pathval(); |
@@ -9944,7 +9944,7 @@ preadfd(void) | |||
9944 | } | 9944 | } |
9945 | } | 9945 | } |
9946 | #else | 9946 | #else |
9947 | nr = nonblock_safe_read(g_parsefile->fd, buf, IBUFSIZ - 1); | 9947 | nr = nonblock_safe_read(g_parsefile->pf_fd, buf, IBUFSIZ - 1); |
9948 | #endif | 9948 | #endif |
9949 | 9949 | ||
9950 | #if 0 | 9950 | #if 0 |
@@ -10171,7 +10171,7 @@ pushfile(void) | |||
10171 | 10171 | ||
10172 | pf = ckzalloc(sizeof(*pf)); | 10172 | pf = ckzalloc(sizeof(*pf)); |
10173 | pf->prev = g_parsefile; | 10173 | pf->prev = g_parsefile; |
10174 | pf->fd = -1; | 10174 | pf->pf_fd = -1; |
10175 | /*pf->strpush = NULL; - ckzalloc did it */ | 10175 | /*pf->strpush = NULL; - ckzalloc did it */ |
10176 | /*pf->basestrpush.prev = NULL;*/ | 10176 | /*pf->basestrpush.prev = NULL;*/ |
10177 | g_parsefile = pf; | 10177 | g_parsefile = pf; |
@@ -10183,8 +10183,8 @@ popfile(void) | |||
10183 | struct parsefile *pf = g_parsefile; | 10183 | struct parsefile *pf = g_parsefile; |
10184 | 10184 | ||
10185 | INT_OFF; | 10185 | INT_OFF; |
10186 | if (pf->fd >= 0) | 10186 | if (pf->pf_fd >= 0) |
10187 | close(pf->fd); | 10187 | close(pf->pf_fd); |
10188 | free(pf->buf); | 10188 | free(pf->buf); |
10189 | while (pf->strpush) | 10189 | while (pf->strpush) |
10190 | popstring(); | 10190 | popstring(); |
@@ -10211,9 +10211,9 @@ static void | |||
10211 | closescript(void) | 10211 | closescript(void) |
10212 | { | 10212 | { |
10213 | popallfiles(); | 10213 | popallfiles(); |
10214 | if (g_parsefile->fd > 0) { | 10214 | if (g_parsefile->pf_fd > 0) { |
10215 | close(g_parsefile->fd); | 10215 | close(g_parsefile->pf_fd); |
10216 | g_parsefile->fd = 0; | 10216 | g_parsefile->pf_fd = 0; |
10217 | } | 10217 | } |
10218 | } | 10218 | } |
10219 | 10219 | ||
@@ -10229,7 +10229,7 @@ setinputfd(int fd, int push) | |||
10229 | pushfile(); | 10229 | pushfile(); |
10230 | g_parsefile->buf = NULL; | 10230 | g_parsefile->buf = NULL; |
10231 | } | 10231 | } |
10232 | g_parsefile->fd = fd; | 10232 | g_parsefile->pf_fd = fd; |
10233 | if (g_parsefile->buf == NULL) | 10233 | if (g_parsefile->buf == NULL) |
10234 | g_parsefile->buf = ckmalloc(IBUFSIZ); | 10234 | g_parsefile->buf = ckmalloc(IBUFSIZ); |
10235 | g_parsefile->left_in_buffer = 0; | 10235 | g_parsefile->left_in_buffer = 0; |
@@ -13562,7 +13562,7 @@ int ash_main(int argc UNUSED_PARAM, char **argv) | |||
13562 | * Ensure we don't falsely claim that 0 (stdin) | 13562 | * Ensure we don't falsely claim that 0 (stdin) |
13563 | * is one of stacked source fds. | 13563 | * is one of stacked source fds. |
13564 | * Testcase: ash -c 'exec 1>&0' must not complain. */ | 13564 | * Testcase: ash -c 'exec 1>&0' must not complain. */ |
13565 | // if (!sflag) g_parsefile->fd = -1; | 13565 | // if (!sflag) g_parsefile->pf_fd = -1; |
13566 | // ^^ not necessary since now we special-case fd 0 | 13566 | // ^^ not necessary since now we special-case fd 0 |
13567 | // in is_hidden_fd() to not be considered "hidden fd" | 13567 | // in is_hidden_fd() to not be considered "hidden fd" |
13568 | evalstring(minusc, 0); | 13568 | evalstring(minusc, 0); |