summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Hellermann2013-03-03 15:29:32 +0100
committerDenys Vlasenko2013-03-15 02:37:51 +0100
commitaeb717aa5e8a5ae650a283306091a2872628cffd (patch)
tree60cf856dd17adff48b1a484d228b632763b65062
parent9e7c002182d2ce57ac23dc65dde23e5f1f6557f0 (diff)
downloadbusybox-aeb717aa5e8a5ae650a283306091a2872628cffd.zip
busybox-aeb717aa5e8a5ae650a283306091a2872628cffd.tar.gz
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>
-rw-r--r--shell/ash.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 0b5111a..5f09fd4 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -13191,19 +13191,6 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
setstackmark(&smark);
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] == '-')
isloginsh = 1;
if (isloginsh) {
@@ -13243,6 +13230,15 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
#if MAX_HISTORY > 0 && ENABLE_FEATURE_EDITING_SAVEHISTORY
if (iflag) {
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)
line_input_state->hist_file = hp;
# if ENABLE_FEATURE_SH_HISTFILESIZE