Bug#317773: LC_ALL=C foo, where foo is a shell function

2008-02-21 Thread Peter Stephenson
On Sun, Jul 10, 2005 at 12:57:47AM +, Bart Schaefer wrote:
 I just noticed that, even in the latest build, if LC_ALL starts out set
 (even to nothing), but not exported, then when LC_ALL=C foo is run
 LC_ALL becomes and remains exported, even though its value gets reset
 to the previous state.

There are two completely separate parts of the shell that restore
parameters.  There is one I wrote for function scope, and there is a second
one that someone else wrote without taking any notice of the first one that
restores parameters in this case.  (Good job I never get bitter, eh?)  This
second one doesn't take account of restoring a special parameter when the
local value is exported and the old value isn't.  For specials there is
always an entry in the table, so this applies even if LC_ALL isn't actually
set.

It should just be a case of removing stuff from the environment if we know
it shouldn't be there.  I can't see any cases when this would be wrong,
anyway.  (There are POSIX exceptions, which I don't think cover LC_ALL
anyway, where the value is preserved after the function call, but none that
would force an export to be inconsistent with the local value.)

Index: Src/exec.c
===
RCS file: /cvsroot/zsh/zsh/Src/exec.c,v
retrieving revision 1.128
diff -u -r1.128 exec.c
--- Src/exec.c  9 Dec 2007 23:53:33 -   1.128
+++ Src/exec.c  21 Feb 2008 18:14:41 -
@@ -3113,6 +3113,8 @@
DPUTS(!tpm || PM_TYPE(pm-node.flags) != 
PM_TYPE(tpm-node.flags) ||
  !(pm-node.flags  PM_SPECIAL),
  BUG: in restoring special parameters);
+   if (!pm-env  tpm-env)
+   delenv(tpm);
tpm-node.flags = pm-node.flags;
switch (PM_TYPE(pm-node.flags)) {
case PM_SCALAR:


-- 
Peter Stephenson [EMAIL PROTECTED]  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK  Tel: +44 (0)1223 692070



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Bug#317773: LC_ALL=C foo, where foo is a shell function

2008-01-29 Thread Clint Adams
[moved to -workers]

On Sat, Apr 14, 2007 at 01:18:31PM -0700, Bart Schaefer wrote:
 I'm not able to reproduce it with the latest CVS on my RHEL4 machine, or
 at least I can't do so with the most straightforward interpretation of
 LC_ALL starts out set.
 
 If it is happening, it has to be related to this (params.c):
 
 void
 lc_allsetfn(Param pm, char *x)
 {
   strsetfn(pm, x);
   if (!x) {
   queue_signals();
   setlang(getsparam(LANG));
   unqueue_signals();
   }
   else
   setlocale(LC_ALL, x);
 }

I just tried and succeeded in reproducing the problem again.  So the
issue is that setlocale() is exporting LC_ALL, but at no point is the
shell aware of this?



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Bug#317773: LC_ALL=C foo, where foo is a shell function

2007-04-14 Thread Clint Adams
On Sun, Jul 10, 2005 at 12:57:47AM +, Bart Schaefer wrote:
 Ah.  I tried it with the latest -dev version, compiled out of my CVS
 sandbox.
 
 If I try with 4.2.5, I get the same results as you.
 
 I just noticed that, even in the latest build, if LC_ALL starts out set
 (even to nothing), but not exported, then when LC_ALL=C foo is run
 LC_ALL becomes and remains exported, even though its value gets reset
 to the previous state.
 
 I don't know what differs between 4.2.5 and the latest CVS that would
 affect this.

I'm think seeing the same behavior in current CVS.


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Bug#317773: LC_ALL=C foo, where foo is a shell function

2007-04-14 Thread Bart Schaefer
On Apr 14,  3:38pm, Clint Adams wrote:
}
} On Sun, Jul 10, 2005 at 12:57:47AM +, Bart Schaefer wrote:
}  I just noticed

Nearly two years ago.  Phrases like just now certainly take on a
different flavor in the face of permanent archival ...

}  that, even in the latest build, if LC_ALL starts out set
}  (even to nothing), but not exported, then when LC_ALL=C foo is run
}  LC_ALL becomes and remains exported, even though its value gets reset
}  to the previous state.
} 
} I'm think seeing the same behavior in current CVS.

I'm not able to reproduce it with the latest CVS on my RHEL4 machine, or
at least I can't do so with the most straightforward interpretation of
LC_ALL starts out set.

If it is happening, it has to be related to this (params.c):

void
lc_allsetfn(Param pm, char *x)
{
strsetfn(pm, x);
if (!x) {
queue_signals();
setlang(getsparam(LANG));
unqueue_signals();
}
else
setlocale(LC_ALL, x);
}



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]