aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2020-02-15 13:25:04 +0000
committerRon Yorston <rmy@pobox.com>2020-02-15 13:25:04 +0000
commit0abe89bc214c9d1f16f32c4339792066b875b7c6 (patch)
tree3748f654565bd08513093ebfbb68487f612b5e3f /shell
parent6885083a7e4f94938ca0a98e2c6c69a84eb08a1f (diff)
parenta6e48dead331c3c19e070992d2d571e74a1d9a8d (diff)
downloadbusybox-w32-0abe89bc214c9d1f16f32c4339792066b875b7c6.tar.gz
busybox-w32-0abe89bc214c9d1f16f32c4339792066b875b7c6.tar.bz2
busybox-w32-0abe89bc214c9d1f16f32c4339792066b875b7c6.zip
Merge branch 'busybox' into merge
Diffstat (limited to 'shell')
-rw-r--r--shell/ash.c60
-rw-r--r--shell/hush.c17
2 files changed, 56 insertions, 21 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 1b7fa9849..29cdd38f6 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -10190,6 +10190,11 @@ evalpipe(union node *n, int flags)
10190 return status; 10190 return status;
10191} 10191}
10192 10192
10193/* setinteractive needs this forward reference */
10194#if EDITING_HAS_get_exe_name
10195static const char *get_builtin_name(int i) FAST_FUNC;
10196#endif
10197
10193/* 10198/*
10194 * Controls whether the shell is interactive or not. 10199 * Controls whether the shell is interactive or not.
10195 */ 10200 */
@@ -10221,8 +10226,12 @@ setinteractive(int on)
10221 } 10226 }
10222#endif 10227#endif
10223#if ENABLE_FEATURE_EDITING 10228#if ENABLE_FEATURE_EDITING
10224 if (!line_input_state) 10229 if (!line_input_state) {
10225 line_input_state = new_line_input_t(FOR_SHELL | WITH_PATH_LOOKUP); 10230 line_input_state = new_line_input_t(FOR_SHELL | WITH_PATH_LOOKUP);
10231# if EDITING_HAS_get_exe_name
10232 line_input_state->get_exe_name = get_builtin_name;
10233# endif
10234 }
10226#endif 10235#endif
10227 } 10236 }
10228} 10237}
@@ -10690,6 +10699,14 @@ find_builtin(const char *name)
10690 return bp; 10699 return bp;
10691} 10700}
10692 10701
10702#if EDITING_HAS_get_exe_name
10703static const char * FAST_FUNC
10704get_builtin_name(int i)
10705{
10706 return /*i >= 0 &&*/ i < ARRAY_SIZE(builtintab) ? builtintab[i].name + 1 : NULL;
10707}
10708#endif
10709
10693/* 10710/*
10694 * Execute a simple command. 10711 * Execute a simple command.
10695 */ 10712 */
@@ -13834,29 +13851,27 @@ expandstr(const char *ps, int syntax_type)
13834 volatile int saveint; 13851 volatile int saveint;
13835 struct jmploc *volatile savehandler = exception_handler; 13852 struct jmploc *volatile savehandler = exception_handler;
13836 struct jmploc jmploc; 13853 struct jmploc jmploc;
13854 const char *volatile result;
13855 int err;
13837 13856
13838 /* XXX Fix (char *) cast. */ 13857 /* XXX Fix (char *) cast. */
13839 setinputstring((char *)ps); 13858 setinputstring((char *)ps);
13840 13859
13841 saveprompt = doprompt; 13860 saveprompt = doprompt;
13842 doprompt = 0; 13861 doprompt = 0;
13862 result = ps;
13863
13864 SAVE_INT(saveint);
13865 err = setjmp(jmploc.loc);
13866 if (err)
13867 goto out;
13843 13868
13844 /* readtoken1() might die horribly. 13869 /* readtoken1() might die horribly.
13845 * Try a prompt with syntactically wrong command: 13870 * Try a prompt with syntactically wrong command:
13846 * PS1='$(date "+%H:%M:%S) > ' 13871 * PS1='$(date "+%H:%M:%S) > '
13847 */ 13872 */
13848 SAVE_INT(saveint); 13873 exception_handler = &jmploc;
13849 if (setjmp(jmploc.loc) == 0) { 13874 readtoken1(pgetc(), syntax_type, FAKEEOFMARK, 0);
13850 exception_handler = &jmploc;
13851 readtoken1(pgetc(), syntax_type, FAKEEOFMARK, 0);
13852 }
13853 exception_handler = savehandler;
13854 RESTORE_INT(saveint);
13855
13856 doprompt = saveprompt;
13857
13858 /* Try: PS1='`xxx(`' */
13859 unwindfiles(file_stop);
13860 13875
13861 n.narg.type = NARG; 13876 n.narg.type = NARG;
13862 n.narg.next = NULL; 13877 n.narg.next = NULL;
@@ -13866,17 +13881,20 @@ expandstr(const char *ps, int syntax_type)
13866 /* expandarg() might fail too: 13881 /* expandarg() might fail too:
13867 * PS1='$((123+))' 13882 * PS1='$((123+))'
13868 */ 13883 */
13869 SAVE_INT(saveint); 13884 expandarg(&n, NULL, EXP_QUOTED);
13870 if (setjmp(jmploc.loc) == 0) { 13885 result = stackblock();
13871 exception_handler = &jmploc; 13886
13872 expandarg(&n, NULL, EXP_QUOTED); 13887out:
13873 } else if (exception_type == EXEXIT) {
13874 exitshell();
13875 }
13876 exception_handler = savehandler; 13888 exception_handler = savehandler;
13889 if (err && exception_type != EXERROR)
13890 longjmp(exception_handler->loc, 1);
13877 RESTORE_INT(saveint); 13891 RESTORE_INT(saveint);
13878 13892
13879 return stackblock(); 13893 doprompt = saveprompt;
13894 /* Try: PS1='`xxx(`' */
13895 unwindfiles(file_stop);
13896
13897 return result;
13880} 13898}
13881 13899
13882static inline int 13900static inline int
diff --git a/shell/hush.c b/shell/hush.c
index 97202b953..6e44d4e11 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -7889,6 +7889,20 @@ static const struct built_in_command *find_builtin(const char *name)
7889 return find_builtin_helper(name, bltins2, &bltins2[ARRAY_SIZE(bltins2)]); 7889 return find_builtin_helper(name, bltins2, &bltins2[ARRAY_SIZE(bltins2)]);
7890} 7890}
7891 7891
7892#if EDITING_HAS_get_exe_name
7893static const char * FAST_FUNC get_builtin_name(int i)
7894{
7895 if (/*i >= 0 && */ i < ARRAY_SIZE(bltins1)) {
7896 return bltins1[i].b_cmd;
7897 }
7898 i -= ARRAY_SIZE(bltins1);
7899 if (i < ARRAY_SIZE(bltins2)) {
7900 return bltins2[i].b_cmd;
7901 }
7902 return NULL;
7903}
7904#endif
7905
7892static void remove_nested_vars(void) 7906static void remove_nested_vars(void)
7893{ 7907{
7894 struct variable *cur; 7908 struct variable *cur;
@@ -10268,6 +10282,9 @@ int hush_main(int argc, char **argv)
10268 10282
10269# if ENABLE_FEATURE_EDITING 10283# if ENABLE_FEATURE_EDITING
10270 G.line_input_state = new_line_input_t(FOR_SHELL); 10284 G.line_input_state = new_line_input_t(FOR_SHELL);
10285# if EDITING_HAS_get_exe_name
10286 G.line_input_state->get_exe_name = get_builtin_name;
10287# endif
10271# endif 10288# endif
10272# if ENABLE_HUSH_SAVEHISTORY && MAX_HISTORY > 0 10289# if ENABLE_HUSH_SAVEHISTORY && MAX_HISTORY > 0
10273 { 10290 {