Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: c6386d3ae034c011924a32fd6a3b6971c7e21a5b
Ticket: 3432962fffffffffffffffffffffffffffffffff
Some noninteractive invocations of tclsh still run .tclshrc
User & Date: karll on 2011-11-04 03:56:08
Changes

  1. icomment:
    I am the inventor of .tclshrc, which first appeared in TclX in, like, 1991.  My intention in making it that tclshrc only be loaded when Tcl is used interactively was to prevent peoples' tclshrc files from changing the behavior of noninteractive Tcl programs, preventing "spooky actions at a distance" and also trying to keep people from accidentally distributing programs with subtle dependencies on something that's done in their tclshrc file, that they might not even realize, like loading some package.
    
    I'm not proposing changing tcl_interactive or how it gets set.  I'm not proposing changing how Tcl behaves if it has any arguments on the command line, which is by far the most common noninteractive use. I'm merely asking for the rc file to never be loaded if Tcl isn't interactive, whereas right now it *almost* never is loaded if Tcl isn't interactive.  What's the test for setting tcl_interactive?  It's set to the result of isatty(0).
    
    For the example of a Makefile action, like
    
        echo "pkg_mkIndex ." | tclsh
    
    tcl_interactive will properly be 0.  I assert this is truly noninteractive invocation of tclsh (you'll never get a command prompt) and Tcl agrees with me in that it set tcl_interactive to 0.  All I'm asking is that tclshrc not be loaded when Tcl isn't interactive, which is aligned with its original intention.
    
    The problem was discovered by exactly the problem I was trying to prevent.  One of our developers had a custom tclshrc file that caused 'echo "pkg_mkIndex ." | tclsh' to malfunction, for them and them only, in a subtle way that took hours to track down.
    
    
    
  2. login: "karll"
  3. mimetype: "text/plain"
  4. username: "karll"