Menu

#2873 errors in script does not give error message with correct line number

None
open-duplicate
nobody
None
2026-07-10
2026-07-10
Anonymous
No

Whenever a script is not completely linear (like if () {}, while () {}, etc), error messages tend to give wrong line numbers.

The simplest way to find the offending script line is to spread empty lines into the script, starting from the back, until the reported line number increases. Or put in a lot of debug output.

I understand it's not exactly trivial to get a correct number, as code blocks only get read once, and the error might occur only later. Would it be possible to store the actual line number while reading the script from the file for every new command, and report that in case of an error?

That wouldn't help within commands spread over several lines using the backslash, but it's at least an improvement.

Discussion

  • Ethan Merritt

    Ethan Merritt - 2026-07-10
    • status: open --> open-duplicate
    • Group: -->
    • Priority: -->
     
  • Ethan Merritt

    Ethan Merritt - 2026-07-10
     

Log in to post a comment.