Overview
| Artifact ID: | 26317ed2e67b5d84251de570f1a5d92a94ef41892a04e31492b65775ee70c34d |
|---|---|
| Ticket: | ba68d1e9484a3a92449fdaab4c377b534842c0e0
Errors that occur when using interp eval do not give relevant line number and filename locations |
| User & Date: | anonymous on 2025-02-25 17:00:06 |
Changes
- assignee changed to: "nobody"
- closer changed to: "nobody"
- cmimetype changed to: "text/x-fossil-plain"
- comment changed to:
More details can be found here: https://stackoverflow.com/questions/78134384/how-to-get-line-number-and-filename-locations-for-errors-that-occur-while-using To summarize, though, when an error occurs while using interp eval, the error outputs the location of the interp eval call, rather than the location of the actual erroneous code being evaluated. This may make sense from the perspective of the caller of interp eval. However, it creates difficulties in the context of implementing something like a plugin system that interp evals scripts, as the writers of the plugin scripts would receive less useful information than might be desired. Some example code and their outputs: Example A: #!/bin/sh # This line continues for Tcl, but is a single line for 'sh' \ exec tclsh "$0" ${1+"$@"} ::safe::interpCreate i i eval {expr {"a" + 1}} Example A Output: ./example.tcl can't use non-numeric string as operand of "+" invoked from within "expr {"a" + 1}" invoked from within "i eval {expr {"a" + 1}}" (file "./example.tcl" line 6) Example B: #!/bin/sh # This line continues for Tcl, but is a single line for 'sh' \ exec tclsh "$0" ${1+"$@"} ::safe::interpCreate i i eval [list expr {"a" + 1}] Example B output: ./example.tcl can't use non-numeric string as operand of "+" while executing "expr {"a" + 1}" invoked from within "i eval [list expr {"a" + 1}]" (file "./example.tcl" line 6) Example C: #!/bin/sh # This line continues for Tcl, but is a single line for 'sh' \ exec tclsh "$0" ${1+"$@"} ::safe::interpCreate i i eval [list expr [list "a" + 1]] Example C output: ./example.tcl invalid bareword "a" in expression "a + 1"; should be "$a" or "{a}" or "a(...)" or ... (parsing expression "a + 1") invoked from within "expr {a + 1}" invoked from within "i eval [list expr [list "a" + 1]]" (file "./example.tcl" line 6) - foundin changed to: "9.0"
- is_private changed to: "0"
- login: "anonymous"
- priority changed to: "5 Medium"
- private_contact changed to: "ac2378affc3f3ba3bd2cd1d1f0d09395d3a439be"
- resolution changed to: "None"
- severity changed to: "Minor"
- status changed to: "Open"
- submitter changed to: "anonymous"
- subsystem changed to: "20. [interp]"
- title changed to:
Errors that occur when using interp eval do not give relevant line number and filename locations
- type changed to: "Bug"