Bug was discovered when trying to unset env(COLUMNS) set by tclreadline. Since any loaded extension can modify the environment with setenv/putenv, Tcl must try to read an environment variable before unsetting it. Here's a simple example to reproduce it:
$ cat setenv.c
#include <tcl.h>
#include <stdlib.h>
int Setenv_Init(Tcl_Interp *interp)
{
if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) {
return TCL_ERROR;
}
if (Tcl_PkgProvide(interp, "Setenv", "1.0") == TCL_ERROR) {
return TCL_ERROR;
}
setenv("MYVAR", "MYVAL", 0);
return TCL_OK;
}
$ gcc -shared -o libsetenv.so -DUSE_TCL_STUBS -I/usr/include/ setenv.c -L/usr/lib64 -ltclstub8.6
$ tclsh
[~] load ./libsetenv.so
[~] unset env(MYVAR)
can't unset "env(MYVAR)": no such element in array
[~] puts $env(MYVAR)
MYVAL
Note that `array unset env MYVAR` works.
|