}
/*
- * 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);
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;
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;
#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) {
* "bash <script>" (which is never interactive (unless -i?))
* sources $BASH_ENV here (without scanning $PATH).
* If called as sh, does the same but with $ENV.
+ * Also NB, per POSIX, $ENV should undergo parameter expansion.
*/
G.global_argc--;
G.global_argv++;