Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
lua命令lua-e“;打印(“hello”)输出为零_Lua_Sh - Fatal编程技术网

lua命令lua-e“;打印(“hello”)输出为零

lua命令lua-e“;打印(“hello”)输出为零,lua,sh,Lua,Sh,当我在linux shell中编写“lua-e”print(“hello”)”,但输出为:nil, “lua-e”print(1)”的输出是:1,这让我感到困惑。 如何在shell上打印“hello”?lua-e“print(“hello”)”在shell中编写的与lua-e“print(hello)”相同,因为shell解析了引号。Shell将您的参数解释为3个字符串的串联:“print”(,hello和”) 因此,Lua打印全局变量hello,它是nil 请尝试lua-e“print(“he

当我在linux shell中编写“lua-e”print(“hello”)”,但输出为:nil,
“lua-e”print(1)”的输出是:1,这让我感到困惑。
如何在shell上打印“hello”?

lua-e“print(“hello”)”
在shell中编写的与
lua-e“print(hello)”相同,因为shell解析了引号。Shell将您的参数解释为3个字符串的串联:
“print”(
hello
”)

因此,Lua打印全局变量
hello
,它是
nil

请尝试
lua-e“print(“hello”)”
以保护引号不受shell解析的影响

lua -e "print(1)"  --output: 1
lua -e "print("hello")" --output: nil