TeX file:
\directlua{require "foo"}
\show\foo
\bye
and the contents of foo.lua:
token.set_macro("foo","\\a\\b\\u\\z")
Here is the result:
> \foo=macro:
->BADa\b \u BADz.
l.2 \show\foo
Why do some backslashes turn into BAD while others work like expected?
I think it might be a bug, but ask here first in case I have a fundamental misunderstanding.
\ais not defined in plain, while\bis. If you add\def\a{blub}it changes. This looks like a bug to me (and I have no idea how to get \ working). – Ulrike Fischer Dec 10 '19 at 16:05\def\gobble#1{}\gobble{\a\z}would "fix" it too. That's basically what the LuaTeX manual is talking about in "10.6.6 Nota bene". – Marcel Krüger Dec 10 '19 at 16:22\\or\!? Whatever I do they end up asBAD!. – Ulrike Fischer Dec 10 '19 at 16:30