diff options
author | jilles <jilles@FreeBSD.org> | 2011-06-10 22:42:00 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2011-06-10 22:42:00 +0000 |
commit | 742a97ee0a4a2d4cabdc097c1fed047d490b5ffb (patch) | |
tree | c5fb621bdc139a5db6a325ed51d8cf1472a19da1 /bin/sh/main.c | |
parent | 82f98a6104c483238c9fcd8df34533f404ba26e6 (diff) | |
download | FreeBSD-src-742a97ee0a4a2d4cabdc097c1fed047d490b5ffb.zip FreeBSD-src-742a97ee0a4a2d4cabdc097c1fed047d490b5ffb.tar.gz |
sh: Do parameter expansion on ENV before using it.
This is required by POSIX, and allows things like ENV=\$HOME/.shrc.
Note that tilde expansion is explicitly not performed.
Diffstat (limited to 'bin/sh/main.c')
-rw-r--r-- | bin/sh/main.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/bin/sh/main.c b/bin/sh/main.c index 9cef1b0..2135d30 100644 --- a/bin/sh/main.c +++ b/bin/sh/main.c @@ -78,7 +78,7 @@ int rootshell; struct jmploc main_handler; int localeisutf8, initial_localeisutf8; -static void read_profile(const char *); +static void read_profile(char *); static char *find_dot_file(char *); /* @@ -92,7 +92,7 @@ static char *find_dot_file(char *); int main(int argc, char *argv[]) { - struct stackmark smark; + struct stackmark smark, smark2; volatile int state; char *shinit; @@ -139,6 +139,7 @@ main(int argc, char *argv[]) rootshell = 1; init(); setstackmark(&smark); + setstackmark(&smark2); procargs(argc, argv); pwd_init(iflag); if (iflag) @@ -163,6 +164,7 @@ state2: } state3: state = 4; + popstackmark(&smark2); if (minusc) { evalstring(minusc, sflag ? 0 : EV_EXIT); } @@ -235,12 +237,16 @@ cmdloop(int top) */ static void -read_profile(const char *name) +read_profile(char *name) { int fd; + const char *expandedname; + expandedname = expandstr(name); + if (expandedname == NULL) + return; INTOFF; - if ((fd = open(name, O_RDONLY)) >= 0) + if ((fd = open(expandedname, O_RDONLY)) >= 0) setinputfd(fd, 1); INTON; if (fd < 0) |