The program 'lua' prints error message that contain contextual data from the user, presumably to help debug the problem.
In my opinion, the program 'lua' should not make any assumptions about the value of this user data, and should ensure that it does not affect the channel that the error message is sent over:
- Non-string values should be converted to a suitable string containing printable characters only (eg '<table 0x12345>', 'false', '123.4').
- String values should be converted into a form containing printable characters only (perhaps by escaping all non-printable characters).
- Long values should be truncated so that the channel is not overloaded (100 characters? 1000? 10000? It all depends), and some indication given if any data has been omitted (perhaps using an ellipsis '...')
The program 'lua' might do the equivalent of string.format('q') on the user data before printing it as part of an error message. It does not matter that the format is not exactly as the user entered it, as long as it is contains an unambiguous representation of the original data.
Personally, I would prefer to see escaped value in hexadecimal rather than decimal ('\x0d' rather than '\13'), and also to see '\x0a' (or '\10') rather than the backslash-escaped newline.
This affects user data that the program 'lua' prints as part of an error message. Any data that the user program sends to any output device using the functions print() or io.write() or friends must be sent to the output device unmodified.