【问题标题】:lua command lua -e "print("hello") output is nillua 命令 lua -e "print("hello") 输出为 nil
【发布时间】:2018-03-02 15:54:08
【问题描述】:
lua -e "print(1)"  --output: 1
lua -e "print("hello")" --output: nil

当我在 linux shell 中写 'lua -e "print("hello"))"' 时,输出为:nil,
'lua -e "print(1)"' 输出为:1,这让我很困惑。
如何在 shell 上打印“hello”?

【问题讨论】:

    标签: lua sh


    【解决方案1】:

    lua -e "print("hello")" 写在 shell 中与 lua -e 'print(hello)' 相同,因为 shell 会解析引号。 Shell 将您的参数解释为 3 个字符串的串联:"print("hello")"
    因此,Lua 打印出全局变量 hello,即 nil
    尝试lua -e 'print("hello")' 保护引号免受shell 解析。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-06-14
      • 1970-01-01
      • 2017-06-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多