diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-09-12 17:57:19 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-09-12 17:57:19 +0200 |
| commit | d7686c8c2c849c775007c5de19901ab6b38bd039 (patch) | |
| tree | 8d4017407166a4f16a0fecd7921a8d03975636bf /shell | |
| parent | e7aa0d9eca180f77ed4226ecaa1e8961d842add7 (diff) | |
| download | busybox-w32-1_15_1.tar.gz busybox-w32-1_15_1.tar.bz2 busybox-w32-1_15_1.zip | |
Apply post-1.15.0 fixes; bump version to 1.15.11_15_1
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
| -rw-r--r-- | shell/ash.c | 2 | ||||
| -rw-r--r-- | shell/hush.c | 61 |
2 files changed, 59 insertions, 4 deletions
diff --git a/shell/ash.c b/shell/ash.c index 077f5e5fc..4a163ffbc 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
| @@ -5810,7 +5810,7 @@ argstr(char *p, int flag, struct strlist *var_str_list) | |||
| 5810 | }; | 5810 | }; |
| 5811 | const char *reject = spclchars; | 5811 | const char *reject = spclchars; |
| 5812 | int c; | 5812 | int c; |
| 5813 | int quotes = flag & (EXP_FULL | EXP_CASE); /* do CTLESC */ | 5813 | int quotes = flag & (EXP_FULL | EXP_CASE | EXP_REDIR); /* do CTLESC */ |
| 5814 | int breakall = flag & EXP_WORD; | 5814 | int breakall = flag & EXP_WORD; |
| 5815 | int inquotes; | 5815 | int inquotes; |
| 5816 | size_t length; | 5816 | size_t length; |
diff --git a/shell/hush.c b/shell/hush.c index 7ac29ace2..5794b1ddf 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
| @@ -58,7 +58,7 @@ | |||
| 58 | * TODOs: | 58 | * TODOs: |
| 59 | * grep for "TODO" and fix (some of them are easy) | 59 | * grep for "TODO" and fix (some of them are easy) |
| 60 | * builtins: ulimit | 60 | * builtins: ulimit |
| 61 | * special variables (PWD etc) | 61 | * special variables (done: PWD) |
| 62 | * follow IFS rules more precisely, including update semantics | 62 | * follow IFS rules more precisely, including update semantics |
| 63 | * export builtin should be special, its arguments are assignments | 63 | * export builtin should be special, its arguments are assignments |
| 64 | * and therefore expansion of them should be "one-word" expansion: | 64 | * and therefore expansion of them should be "one-word" expansion: |
| @@ -1432,6 +1432,13 @@ static int set_local_var(char *str, int flg_export, int local_lvl, int flg_read_ | |||
| 1432 | return 0; | 1432 | return 0; |
| 1433 | } | 1433 | } |
| 1434 | 1434 | ||
| 1435 | /* Used at startup and after each cd */ | ||
| 1436 | static void set_pwd_var(int exp) | ||
| 1437 | { | ||
| 1438 | set_local_var(xasprintf("PWD=%s", get_cwd(/*force:*/ 1)), | ||
| 1439 | /*exp:*/ exp, /*lvl:*/ 0, /*ro:*/ 0); | ||
| 1440 | } | ||
| 1441 | |||
| 1435 | static int unset_local_var_len(const char *name, int name_len) | 1442 | static int unset_local_var_len(const char *name, int name_len) |
| 1436 | { | 1443 | { |
| 1437 | struct variable *cur; | 1444 | struct variable *cur; |
| @@ -1604,6 +1611,9 @@ static const char* setup_prompt_string(int promptmode) | |||
| 1604 | /* Set up the prompt */ | 1611 | /* Set up the prompt */ |
| 1605 | if (promptmode == 0) { /* PS1 */ | 1612 | if (promptmode == 0) { /* PS1 */ |
| 1606 | free((char*)G.PS1); | 1613 | free((char*)G.PS1); |
| 1614 | /* bash uses $PWD value, even if it is set by user. | ||
| 1615 | * It uses current dir only if PWD is unset. | ||
| 1616 | * We always use current dir. */ | ||
| 1607 | G.PS1 = xasprintf("%s %c ", get_cwd(0), (geteuid() != 0) ? '$' : '#'); | 1617 | G.PS1 = xasprintf("%s %c ", get_cwd(0), (geteuid() != 0) ? '$' : '#'); |
| 1608 | prompt_str = G.PS1; | 1618 | prompt_str = G.PS1; |
| 1609 | } else | 1619 | } else |
| @@ -6432,8 +6442,49 @@ int hush_main(int argc, char **argv) | |||
| 6432 | } | 6442 | } |
| 6433 | e++; | 6443 | e++; |
| 6434 | } | 6444 | } |
| 6445 | /* reinstate HUSH_VERSION */ | ||
| 6435 | debug_printf_env("putenv '%s'\n", hush_version_str); | 6446 | debug_printf_env("putenv '%s'\n", hush_version_str); |
| 6436 | putenv((char *)hush_version_str); /* reinstate HUSH_VERSION */ | 6447 | putenv((char *)hush_version_str); |
| 6448 | |||
| 6449 | /* Export PWD */ | ||
| 6450 | set_pwd_var(/*exp:*/ 1); | ||
| 6451 | /* bash also exports SHLVL and _, | ||
| 6452 | * and sets (but doesn't export) the following variables: | ||
| 6453 | * BASH=/bin/bash | ||
| 6454 | * BASH_VERSINFO=([0]="3" [1]="2" [2]="0" [3]="1" [4]="release" [5]="i386-pc-linux-gnu") | ||
| 6455 | * BASH_VERSION='3.2.0(1)-release' | ||
| 6456 | * HOSTTYPE=i386 | ||
| 6457 | * MACHTYPE=i386-pc-linux-gnu | ||
| 6458 | * OSTYPE=linux-gnu | ||
| 6459 | * HOSTNAME=<xxxxxxxxxx> | ||
| 6460 | * PPID=<NNNNN> | ||
| 6461 | * EUID=<NNNNN> | ||
| 6462 | * UID=<NNNNN> | ||
| 6463 | * GROUPS=() | ||
| 6464 | * LINES=<NNN> | ||
| 6465 | * COLUMNS=<NNN> | ||
| 6466 | * BASH_ARGC=() | ||
| 6467 | * BASH_ARGV=() | ||
| 6468 | * BASH_LINENO=() | ||
| 6469 | * BASH_SOURCE=() | ||
| 6470 | * DIRSTACK=() | ||
| 6471 | * PIPESTATUS=([0]="0") | ||
| 6472 | * HISTFILE=/<xxx>/.bash_history | ||
| 6473 | * HISTFILESIZE=500 | ||
| 6474 | * HISTSIZE=500 | ||
| 6475 | * MAILCHECK=60 | ||
| 6476 | * PATH=/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:. | ||
| 6477 | * SHELL=/bin/bash | ||
| 6478 | * SHELLOPTS=braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor | ||
| 6479 | * TERM=dumb | ||
| 6480 | * OPTERR=1 | ||
| 6481 | * OPTIND=1 | ||
| 6482 | * IFS=$' \t\n' | ||
| 6483 | * PS1='\s-\v\$ ' | ||
| 6484 | * PS2='> ' | ||
| 6485 | * PS4='+ ' | ||
| 6486 | */ | ||
| 6487 | |||
| 6437 | #if ENABLE_FEATURE_EDITING | 6488 | #if ENABLE_FEATURE_EDITING |
| 6438 | G.line_input_state = new_line_input_t(FOR_SHELL); | 6489 | G.line_input_state = new_line_input_t(FOR_SHELL); |
| 6439 | #endif | 6490 | #endif |
| @@ -6816,7 +6867,11 @@ static int FAST_FUNC builtin_cd(char **argv) | |||
| 6816 | bb_perror_msg("cd: %s", newdir); | 6867 | bb_perror_msg("cd: %s", newdir); |
| 6817 | return EXIT_FAILURE; | 6868 | return EXIT_FAILURE; |
| 6818 | } | 6869 | } |
| 6819 | get_cwd(1); | 6870 | /* Read current dir (get_cwd(1) is inside) and set PWD. |
| 6871 | * Note: do not enforce exporting. If PWD was unset or unexported, | ||
| 6872 | * set it again, but do not export. bash does the same. | ||
| 6873 | */ | ||
| 6874 | set_pwd_var(/*exp:*/ 0); | ||
| 6820 | return EXIT_SUCCESS; | 6875 | return EXIT_SUCCESS; |
| 6821 | } | 6876 | } |
| 6822 | 6877 | ||
