Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] Fix ENV handling in sh/ksh emulation
- X-seq: zsh-workers 39167
- From: Teubel György <tgyurci@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] Fix ENV handling in sh/ksh emulation
- Date: Sat, 3 Sep 2016 23:06:30 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id; bh=ziG6PWRkN+p4fA/jwzsmyZPYvuk9nkSv4lL3ittZZXQ=; b=Q0FXFEvg5xKJN8sWJiKohYlWZvtard5AlknH6P/Ul4eFRvzzRwF9ZTupsFTZ3x0FeF HZjRWwZnaiXK/8m1Tdu+HgPW2FsU5uhQIavjNSSUF4iDJGtVaY+yJv5NnDA+JvuyRrOp JUYHvUxLjSPtaeay2g7DEUy9ncvurDBXdje/ITK1yC8O9Mz3Lif4K38J999lfYhAHkf0 V0RGu6jtGMwLTFaXsWBx5V1AJ0QCIQb/uTfTjxrl9ZVTB2tEVD1mFfHTo20LQCWmzA/G G83ZJmeAfYDjs4QltjVIUuotcxUZDIUaurBoCrpNyspRWTQ6jX18bNirlGAX8i6YF3+R KBnQ==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
At sh/ksh emulation the value of the ENV parameter is stored
before sourcing ~/.profile. Hence setting the ENV parameter
in ~/.profile has no effect.
Additionally the ENV is sourced regardless of the interactive state of
the shell. POSIX standard says that the ENV should be sourced
when and only when an interactive shell is invoked.
---
Doc/Zsh/params.yo | 3 ++-
Src/init.c | 25 ++++++++++++++-----------
2 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/Doc/Zsh/params.yo b/Doc/Zsh/params.yo
index 55930ed..03625ce 100644
--- a/Doc/Zsh/params.yo
+++ b/Doc/Zsh/params.yo
@@ -1059,7 +1059,8 @@ If the tt(ENV) environment variable is set when zsh is invoked as tt(sh)
or tt(ksh), tt($ENV) is sourced after the profile scripts. The value of
tt(ENV) is subjected to parameter expansion, command substitution, and
arithmetic expansion before being interpreted as a pathname. Note that
-tt(ENV) is em(not) used unless zsh is emulating bf(sh) or bf(ksh).
+tt(ENV) is em(not) used unless the shell is interactive and zsh is
+emulating bf(sh) or bf(ksh).
)
vindex(FCEDIT)
item(tt(FCEDIT))(
diff --git a/Src/init.c b/Src/init.c
index 20a07eb..3dea179 100644
--- a/Src/init.c
+++ b/Src/init.c
@@ -712,7 +712,7 @@ init_term(void)
if (tgetent(termbuf, term) != TGETENT_SUCCESS)
#endif
{
- if (isset(INTERACTIVE))
+ if (interact)
zerr("can't find terminal definition for %s", term);
errflag &= ~ERRFLAG_ERROR;
termflags |= TERM_BAD;
@@ -1205,19 +1205,22 @@ run_init_scripts(void)
if (islogin)
source("/etc/profile");
if (unset(PRIVILEGED)) {
- char *s = getsparam("ENV");
if (islogin)
sourcehome(".profile");
- noerrs = 2;
- if (s) {
- s = dupstring(s);
- if (!parsestr(&s)) {
- singsub(&s);
- noerrs = 0;
- source(s);
+
+ if (interact) {
+ noerrs = 2;
+ char *s = getsparam("ENV");
+ if (s) {
+ s = dupstring(s);
+ if (!parsestr(&s)) {
+ singsub(&s);
+ noerrs = 0;
+ source(s);
+ }
}
+ noerrs = 0;
}
- noerrs = 0;
} else
source("/etc/suid_profile");
} else {
@@ -1227,7 +1230,7 @@ run_init_scripts(void)
if (isset(RCS) && unset(PRIVILEGED))
{
- if (isset(INTERACTIVE)) {
+ if (interact) {
/*
* Always attempt to load the newuser module to perform
* checks for new zsh users. Don't care if we can't load it.
--
2.9.3
Messages sorted by:
Reverse Date,
Date,
Thread,
Author