From e5e089c02cdd47e2b57da2b8a7a4f4fcfe308030 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Sat, 19 May 2018 11:05:33 +0800 Subject: [PATCH] [PATCH] ash history --- include/libbb.h | 4 ++-- init/init.c | 2 +- shell/ash.c | 8 ++++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/include/libbb.h b/include/libbb.h index 709505854..e5ab9be3b 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -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" diff --git a/init/init.c b/init/init.c index 6f3374eac..77c6d03a6 100644 --- a/init/init.c +++ b/init/init.c @@ -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]) diff --git a/shell/ash.c b/shell/ash.c index 881af034d..19ffd0ae8 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -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;