[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Bug report: string escapes can mess up terminal
- From: Daurnimator <quae@...>
- Date: Wed, 16 Aug 2017 12:43:50 +1000
On 16 August 2017 at 12:00, nobody <nobody+lua-list@afra-berlin.de> wrote:
> So what should happen? Escape some (all?) non-printable characters? But
> maybe keep NL? HT? CR?
>
> What about \0? That currently terminates error messages:
>
>> "foo\0bar \u{"
> stdin:1: hexadecimal digit expected near '"foo'
>> error "foo\0bar"
> stdin:1: foo
> stack traceback:
> [...]
>
>
> OTOH, I _do_ like my
>
> Error = { __tostring = function( e ) return e.msg end }
> function oops( msg )
> return error( setmetatable( {
> msg = "\x1b[1;7;31m OOPS \x1b[0;31m "..msg.."\x1b[0m",
> reason = "panic",
> }, Error ) )
> end
> oops "things just went horribly wrong"
>
> so this should only affect Lua's own error messages.
>
> -- nobody
>
I would assume the most sensible option would be to use the same logic
as %q in string.format.