* ksh Emulation Not Clearing Envariables
@ 2004-05-09 0:41 Chris Jepeway
2004-05-09 21:58 ` Bart Schaefer
0 siblings, 1 reply; 9+ messages in thread
From: Chris Jepeway @ 2004-05-09 0:41 UTC (permalink / raw)
To: zsh-users
I ran into some trouble with ksh emulation when trying to get zsh
to work with a ksh88 script. Here's a smallish test case that
illustrates the problem:
emulate ksh
function e {
env | egrep ^X
}
X=one e <<-EEK
Oy
EEK
e
I'd expect the output to be
X=one
Instead, I see
X=one
X=one
Without ksh emulation enabled, I see the expected output.
This, with zsh-4.2.0.
This is a bug, right? If so, should I file a report @ sourceforge.net?
Chris <jepeway@blasted-heath.com>.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: ksh Emulation Not Clearing Envariables
2004-05-09 0:41 ksh Emulation Not Clearing Envariables Chris Jepeway
@ 2004-05-09 21:58 ` Bart Schaefer
2004-05-10 14:52 ` Peter Stephenson
2004-05-11 16:59 ` Chris Jepeway
0 siblings, 2 replies; 9+ messages in thread
From: Bart Schaefer @ 2004-05-09 21:58 UTC (permalink / raw)
To: zsh-users
On Sat, 8 May 2004, Chris Jepeway wrote:
> I'd expect the output to be
>
> X=one
>
> Instead, I see
>
> X=one
> X=one
>
> Without ksh emulation enabled, I see the expected output.
>
> This is a bug, right?
It's the intended behavior. Whether the intention is wrong, I'm not sure.
I believe there was a discussion of the POSIX requirements for this at
some point in the past, and the non-zsh-emulation modes follow POSIX while
(as usual, e.g. shwordsplit) zsh-mode does what it thinks is preferable.
It's possible that ksh also does not follow POSIX and therefore zsh's ksh
emulation shouldn't do so. Or its possible that ksh does two different
things depending on the form of the function declaration, e.g. whether
function e { ... }
vs
e() { ... }
and zsh is only able to emulate one or the other because it does not
distinguish the two the way ksh does. (There is no promise made that zsh
will be able to run ksh scripts unmodified; zsh doesn't support namerefs,
among other things.)
> If so, should I file a report @ sourceforge.net?
I keep thinking we should just disable the bug tracker at sourceforge. I
don't think anyone pays regular attention to it any more. Bug reports are
usually "filed" by sending them to the zsh-workers mailing list.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: ksh Emulation Not Clearing Envariables
2004-05-09 21:58 ` Bart Schaefer
@ 2004-05-10 14:52 ` Peter Stephenson
2004-05-11 17:03 ` Chris Jepeway
2004-05-11 16:59 ` Chris Jepeway
1 sibling, 1 reply; 9+ messages in thread
From: Peter Stephenson @ 2004-05-10 14:52 UTC (permalink / raw)
To: zsh-users
Bart Schaefer wrote:
> On Sat, 8 May 2004, Chris Jepeway wrote:
>
> > I'd expect the output to be
> >
> > X=one
> >
> > Instead, I see
> >
> > X=one
> > X=one
> >
> > Without ksh emulation enabled, I see the expected output.
> >
> > This is a bug, right?
>
> It's the intended behavior. Whether the intention is wrong, I'm not sure.
> I believe there was a discussion of the POSIX requirements for this at
> some point in the past, and the non-zsh-emulation modes follow POSIX while
> (as usual, e.g. shwordsplit) zsh-mode does what it thinks is preferable.
I vaguely remember the argument years ago...
bash and ksh 88 both remove the environment variable, so probably we
ought to do the same. It would be odd for zsh to insist on niceties
when the shells based more firmly on POSIX don't.
Solaris8 sh doesn't actually bother to set X at all when the command is a
function. Strange.
--
Peter Stephenson <pws@csr.com> Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK Tel: +44 (0)1223 692070
**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.
www.mimesweeper.com
**********************************************************************
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: ksh Emulation Not Clearing Envariables
2004-05-09 21:58 ` Bart Schaefer
2004-05-10 14:52 ` Peter Stephenson
@ 2004-05-11 16:59 ` Chris Jepeway
2004-05-11 17:34 ` Peter Stephenson
1 sibling, 1 reply; 9+ messages in thread
From: Chris Jepeway @ 2004-05-11 16:59 UTC (permalink / raw)
To: Bart Schaefer; +Cc: zsh-users
>
>> I'd expect the output to be
>>
>> X=one
>>
>> Instead, I see
>>
>> X=one
>> X=one
>>
>> Without ksh emulation enabled, I see the expected output.
>>
>> This is a bug, right?
>
> It's the intended behavior. Whether the intention is wrong, I'm not
> sure.
Odd.
POSIX wants the envariable to persist across invocations
of the function "e"? That seems...counter-intuitive.
I thought the whole point of
VAR=val cmd
was as a shortcut to
export VAR=val ; cmd ; unset VAR
nevermind dovetailing with execve()'s env pointer.
Sure, in this case, cmd is a shell function, but...well...so what?
Eeesh. POSIX.
But, anyways, the command is "emulate ksh" not "emulate posix".
Any chance this behavior could change to follow ksh? ksh88 as
distributed w/ Solaris-8 is what I'm using for comparison.
>> Me
> Bart
Chris <jepeway@blasted-heath.com>.
(Oh, hey, could folk cc me on replies? I'm not yet on the list.)
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: ksh Emulation Not Clearing Envariables
2004-05-11 16:59 ` Chris Jepeway
@ 2004-05-11 17:34 ` Peter Stephenson
[not found] ` <040511181944.AA29985.SM@caleb.ins.cwru.edu>
0 siblings, 1 reply; 9+ messages in thread
From: Peter Stephenson @ 2004-05-11 17:34 UTC (permalink / raw)
To: Chris Jepeway; +Cc: zsh-users
Chris Jepeway wrote:
> POSIX wants the envariable to persist across invocations
> of the function "e"? That seems...counter-intuitive.
> I thought the whole point of
>
> VAR=val cmd
>
> was as a shortcut to
>
> export VAR=val ; cmd ; unset VAR
>
> nevermind dovetailing with execve()'s env pointer.
>
> Sure, in this case, cmd is a shell function, but...well...so what?
> Eeesh. POSIX.
>
> But, anyways, the command is "emulate ksh" not "emulate posix".
> Any chance this behavior could change to follow ksh? ksh88 as
> distributed w/ Solaris-8 is what I'm using for comparison.
I can't find it in POSIX now, but it's controlled by the option
posix_builtins. We could turn that off for ksh, but I'd like to know if
we really ever need to have it on by default.
--
Peter Stephenson <pws@csr.com> Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK Tel: +44 (0)1223 692070
**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.
www.mimesweeper.com
**********************************************************************
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2004-05-11 20:39 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-09 0:41 ksh Emulation Not Clearing Envariables Chris Jepeway
2004-05-09 21:58 ` Bart Schaefer
2004-05-10 14:52 ` Peter Stephenson
2004-05-11 17:03 ` Chris Jepeway
2004-05-11 16:59 ` Chris Jepeway
2004-05-11 17:34 ` Peter Stephenson
[not found] ` <040511181944.AA29985.SM@caleb.ins.cwru.edu>
2004-05-11 18:44 ` Chris Jepeway
2004-05-11 20:22 ` Bart Schaefer
[not found] ` <040511192759.AA02456.SM@caleb.ins.cwru.edu>
2004-05-11 20:38 ` Chris Jepeway
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).