diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2016-10-27 12:28:59 +0300 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2016-10-27 12:28:59 +0300 |
commit | 2eb0a7e1b9a579ba34e4780c9ed8e74f38bc6b85 (patch) | |
tree | d02a7697eafd348e66aa1ef17fc5334d7b8f950e /shell/ash.c | |
parent | 70392331a98d266af539be4b910812fc7b0a72d4 (diff) |
ash: [SHELL] Expand ENV before using it
Upstream commit:
Date: Sun, 13 Jul 2008 21:51:52 +0800
[SHELL] Expand ENV before using it
Per POSIX ENV needs to undergo parameter expansion.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/ash.c')
-rw-r--r-- | shell/ash.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/shell/ash.c b/shell/ash.c index 864b8f0a4..0dd440c61 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -13277,11 +13277,12 @@ procargs(char **argv) } /* - * Read /etc/profile or .profile. + * Read /etc/profile, ~/.profile, $ENV. */ static void read_profile(const char *name) { + name = expandstr(name); if (setinputfile(name, INPUT_PUSH_FILE | INPUT_NOFILE_OK) < 0) return; cmdloop(0); @@ -13325,7 +13326,6 @@ extern int etext(); int ash_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int ash_main(int argc UNUSED_PARAM, char **argv) { - const char *shinit; volatile smallint state; struct jmploc jmploc; struct stackmark smark; @@ -13394,11 +13394,8 @@ int ash_main(int argc UNUSED_PARAM, char **argv) state1: state = 2; hp = lookupvar("HOME"); - if (hp) { - hp = concat_path_file(hp, ".profile"); - read_profile(hp); - free((char*)hp); - } + if (hp) + read_profile("$HOME/.profile"); } state2: state = 3; @@ -13408,11 +13405,11 @@ int ash_main(int argc UNUSED_PARAM, char **argv) #endif iflag ) { - shinit = lookupvar("ENV"); - if (shinit != NULL && *shinit != '\0') { + const char *shinit = lookupvar("ENV"); + if (shinit != NULL && *shinit != '\0') read_profile(shinit); - } } + popstackmark(&smark); state3: state = 4; if (minusc) { |