lua-users home
lua-l archive

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


On Thu, Jul 7, 2011 at 4:48 PM, Ross Berteig <Ross@cheshireeng.com> wrote:
>    C:...>lua -e "print(string.format('%q','abc\a'))"
>    "abc"
> It may or may not have emitted the \007 represented by the \a, but if so it
> was visually lost (and it didn't even go 'ding' [...]

Trivia question: What does the following program print?

  $ cat test.lua
  print((('123'):gsub('[^a-z]', '')))

Answer:

  $ lua test.lua
  abc

Note that test.lua was created using

  local fh = assert(io.open('test.lua', 'wb'))
  fh:write"print((('abc\b\b\b123'):gsub('[^a-z]', '')))\n"
  fh:close()

OTOH,

  $ cat -A test.lua
  print((('abc^H^H^H123'):gsub('[^a-z]', '')))$