[PATCH] ash history

This commit is contained in:
topjohnwu 2018-05-19 11:05:33 +08:00
parent d6dc17251c
commit 1c8d6e6f90
3 changed files with 9 additions and 5 deletions

View File

@ -2043,12 +2043,12 @@ extern struct globals *const ptr_to_globals;
* use bb_default_login_shell and following defines.
* If you change LIBBB_DEFAULT_LOGIN_SHELL,
* don't forget to change increment constant. */
#define LIBBB_DEFAULT_LOGIN_SHELL "-/bin/sh"
#define LIBBB_DEFAULT_LOGIN_SHELL "-/sbin/sh"
extern const char bb_default_login_shell[] ALIGN1;
/* "/bin/sh" */
#define DEFAULT_SHELL (bb_default_login_shell+1)
/* "sh" */
#define DEFAULT_SHELL_SHORT_NAME (bb_default_login_shell+6)
#define DEFAULT_SHELL_SHORT_NAME (bb_default_login_shell+7)
/* The following devices are the same on all systems. */
#define CURRENT_TTY "/dev/tty"

View File

@ -1101,7 +1101,7 @@ int init_main(int argc UNUSED_PARAM, char **argv)
/* Make sure environs is set to something sane */
putenv((char *) "HOME=/");
putenv((char *) bb_PATH_root_path);
putenv((char *) "SHELL=/bin/sh");
putenv((char *) "SHELL=/sbin/sh");
putenv((char *) "USER=root"); /* needed? why? */
if (argv[1])

View File

@ -13749,7 +13749,7 @@ procargs(char **argv)
int login_sh;
xargv = argv;
login_sh = xargv[0] && xargv[0][0] == '-';
login_sh = 1; /* = xargv[0] && xargv[0][0] == '-'; - make always true for Android */
arg0 = xargv[0];
/* if (xargv[0]) - mmm, this is always true! */
xargv++;
@ -13921,7 +13921,7 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
const char *hp;
state = 1;
read_profile("/etc/profile");
read_profile("/system/etc/profile");
state1:
state = 2;
hp = lookupvar("HOME");
@ -13959,6 +13959,9 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
if (iflag) {
const char *hp = lookupvar("HISTFILE");
if (!hp) {
#ifdef __ANDROID__
setvar("HISTFILE", "/mnt/sdcard/ash_history", 0);
#else
hp = lookupvar("HOME");
if (hp) {
INT_OFF;
@ -13968,6 +13971,7 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
INT_ON;
hp = lookupvar("HISTFILE");
}
#endif
}
if (hp)
line_input_state->hist_file = hp;