lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Mon, Dec 19, 2011 at 7:43 PM, Patrick Rapin <> wrote:
>> I'd like to ask whether this quotation improvement is guaranteed or
>> not to work in Lua:
>> output:write ((string.gsub (string.format ("bootstrap_image = %q",
>> binary), "\\000", "\0")))
> To my knowledge, yes.
> But I don't get the point to use the %q format modifier along with
> that substitution.
> If you really want the shortest possible result, you can just use a
> long string like in:
> output:write (string.format ("bootstrap_image = [=[%s]=]", binary))
> After having verified that neither [=[ nor ]=] appear in binary (or
> test dynamically the number of = signs to use).

It doesn't work at least due to newline mangling.