mirror of https://github.com/mirror/busybox.git
ash: move code to allow setting $HOME in /etc/profile
move HISTFILE=$HOME/.ash_history below reading /etc/profile, so that /etc/profile can set $HOME. HOME can be unset when directly invoking ash --login from init without going through getty. Signed-off-by: Stefan Hellermann <stefan@the2masters.de> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>1_22_stable
parent
9e7c002182
commit
aeb717aa5e
22
shell/ash.c
22
shell/ash.c
|
@ -13191,19 +13191,6 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
|
||||||
setstackmark(&smark);
|
setstackmark(&smark);
|
||||||
procargs(argv);
|
procargs(argv);
|
||||||
|
|
||||||
#if ENABLE_FEATURE_EDITING_SAVEHISTORY
|
|
||||||
if (iflag) {
|
|
||||||
const char *hp = lookupvar("HISTFILE");
|
|
||||||
if (!hp) {
|
|
||||||
hp = lookupvar("HOME");
|
|
||||||
if (hp) {
|
|
||||||
char *defhp = concat_path_file(hp, ".ash_history");
|
|
||||||
setvar("HISTFILE", defhp, 0);
|
|
||||||
free(defhp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (argv[0] && argv[0][0] == '-')
|
if (argv[0] && argv[0][0] == '-')
|
||||||
isloginsh = 1;
|
isloginsh = 1;
|
||||||
if (isloginsh) {
|
if (isloginsh) {
|
||||||
|
@ -13243,6 +13230,15 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
|
||||||
#if MAX_HISTORY > 0 && ENABLE_FEATURE_EDITING_SAVEHISTORY
|
#if MAX_HISTORY > 0 && ENABLE_FEATURE_EDITING_SAVEHISTORY
|
||||||
if (iflag) {
|
if (iflag) {
|
||||||
const char *hp = lookupvar("HISTFILE");
|
const char *hp = lookupvar("HISTFILE");
|
||||||
|
if (!hp) {
|
||||||
|
hp = lookupvar("HOME");
|
||||||
|
if(hp) {
|
||||||
|
hp = concat_path_file(hp, ".ash_history");
|
||||||
|
setvar("HISTFILE", hp, 0);
|
||||||
|
free((char*)hp);
|
||||||
|
hp = lookupvar("HISTFILE");
|
||||||
|
}
|
||||||
|
}
|
||||||
if (hp)
|
if (hp)
|
||||||
line_input_state->hist_file = hp;
|
line_input_state->hist_file = hp;
|
||||||
# if ENABLE_FEATURE_SH_HISTFILESIZE
|
# if ENABLE_FEATURE_SH_HISTFILESIZE
|
||||||
|
|
Loading…
Reference in New Issue