Tcl Source Code

View Ticket
Login
Ticket UUID: 61f4c677709c542a83abe089b3822e165c45cd09
Title: The info command doesn't care of the working directory if changed by the program
Type: Bug Created on: 2023-06-20 16:02:22
Submitter: geballin Assigned to: nobody
Subsystem: 17. Commands I-L Severity: Minor
Priority: 5 Medium Last modified: 2023-06-20 16:02:22
Status: Open Closed by: nobody
Resolution: None Closed on:
Version: 8.6.13
Description:

This is a bug in the info command. The info command doesn't care of the working directory when changed by the program using a simple cd. This give a bug when used in conjonction with file normalize.

Exemple with this code, run from everywhere using relative file path for launching the script tclsh or source it, it should always find himself which doesn't work :

cd [file dirname [file normalize [info script]]]
set myselfPath [file normalize [info script]]
puts $myselfPath
if {[file exist $myselfPath]} {
  puts "I found myself"
} else {
  puts "I can't find the file $myselfPath which should be myself"
  exit 1
}

A simple way to avoid that kind of bugs will be to have [info script] always return absolute path, even if source or Tcl_EvalFile launched with a relative filename as argument.