*
* @(#) Copyright (c) 1991, 1993 The Regents of the University of California. All rights reserved.
* @(#)main.c 8.6 (Berkeley) 5/28/95
- * $FreeBSD: src/bin/sh/main.c,v 1.49 2011/06/04 15:05:52 jilles Exp $
+ * $FreeBSD: src/bin/sh/main.c,v 1.50 2011/06/10 22:42:00 jilles Exp $
*/
#include <stdio.h>
int
main(int argc, char *argv[])
{
- struct stackmark smark;
+ struct stackmark smark, smark2;
volatile int state;
char *shinit;
rootshell = 1;
init();
setstackmark(&smark);
+ setstackmark(&smark2);
procargs(argc, argv);
pwd_init(iflag);
if (iflag)
}
state3:
state = 4;
+ popstackmark(&smark2);
if (minusc) {
evalstring(minusc, sflag ? 0 : EV_EXIT);
}
read_profile(const char *name)
{
int fd;
+ const char *expandedname;
+ expandedname = expandstr(__DECONST(char *, 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)
.\" SUCH DAMAGE.
.\"
.\" from: @(#)sh.1 8.6 (Berkeley) 5/4/95
-.\" $FreeBSD: src/bin/sh/sh.1,v 1.166 2011/06/09 23:12:23 jilles Exp $
+.\" $FreeBSD: src/bin/sh/sh.1,v 1.167 2011/06/10 22:42:00 jilles Exp $
.\"
.Dd August 21, 2011
.Dt SH 1
.Ev ENV
is set on entry to a shell, or is set in the
.Pa .profile
-of a login shell, the shell then reads commands from the file named in
-.Ev ENV .
+of a login shell, the shell then subjects its value to parameter expansion
+and arithmetic expansion and reads commands from the named file.
Therefore, a user should place commands that are to be executed only
at login time in the
.Pa .profile
--- /dev/null
+# $FreeBSD: src/tools/regression/bin/sh/parameters/env1.0,v 1.1 2011/06/10 22:42:00 jilles Exp $
+
+export key='must contain this'
+unset x
+r=$(ENV="\${x?\$key}" ${SH} -i +m 2>&1 >/dev/null <<\EOF
+exit 0
+EOF
+) && case $r in
+*"$key"*) true ;;
+*) false ;;
+esac