Skip to content
Tcl Source Code History Of Ticket c2a8c0a5f6
Login

History Of Ticket c2a8c0a5f6

Artifacts Associated With Ticket c2a8c0a5f6

  1. Ticket change [b237e6e543] (rid 192833) by anonymous on 2021-03-29 17:22:47:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/plain"
    4. comment initialized to:
      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.
      
    5. foundin initialized to: "8.6.8"
    6. is_private initialized to: "0"
    7. login: "anonymous"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "146dd1e205d9fff77d7951eac899e5ac1489b0a7"
    10. resolution initialized to: "None"
    11. severity initialized to: "Minor"
    12. status initialized to: "Open"
    13. submitter initialized to: "anonymous"
    14. subsystem initialized to: "08. Environment Variables"
    15. title initialized to:
      Tcl should try to read env(VAR) before unsetting it
      
    16. type initialized to: "Bug"