Reputation: 73
lua -e "print(1)" --output: 1
lua -e "print("hello")" --output: nil
When i write 'lua -e "print("hello"))"' in linux shell,but is output was:nil,
'lua -e "print(1)"' output was:1,this make me confused.
How can I print "hello" on the shell?
Upvotes: 3
Views: 277
Reputation: 974
lua -e "print("hello")"
written in shell is the same as lua -e 'print(hello)'
due to parsing quotes by the shell. Shell interprets your argument as concatenation of 3 strings: "print("
, hello
and ")"
.
So, Lua prints global variable hello
which is nil
.
Try lua -e 'print("hello")'
to protect quotes from shell parsing.
Upvotes: 4