xing393939
V2EX  ›  Node.js

Linux 下用 debug 方法调试的疑问( shell 脚本问题)

  •  
  •   xing393939 · Jan 13, 2017 · 2137 views
    This topic created in 3406 days ago, the information mentioned may be changed or developed.
    用了 debug 模块后在 linux 中启动:
    DEBUG=mydebug:* node app.js

    我想知道前面的 DEBUG=mydebug:* 是表示什么意思呢?

    好像也不是定义变量的意思,因为我执行:
    DEBUG=mydebug:* echo ${DEBUG}
    是输出空

    执行:
    DEBUG=mydebug:* && echo ${DEBUG}
    是输出 mydebug:*
    5 replies    2017-01-13 18:26:15 +08:00
    magicdawn
        1
    magicdawn  
       Jan 13, 2017
    DEBUG=mydebug:* echo ${DEBUG}

    解析 DEBUG=空

    执行
    DEBUG=mydebug:* echo
    magicdawn
        2
    magicdawn  
       Jan 13, 2017
    试下这个

    DEBUG=abc sh -c "echo $DEBUG"
    magicdawn
        3
    magicdawn  
       Jan 13, 2017
    是设定环境变量的意思
    TerrenceSun
        5
    TerrenceSun  
       Jan 13, 2017   ❤️ 1
    BASH 下面这可以用,另外,/usr/bin/env 也可以实现相同的功能。
    试下这个
    ```env a=b sh -c 'echo $a'```
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3325 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 42ms · UTC 13:12 · PVG 21:12 · LAX 06:12 · JFK 09:12
    ♥ Do have faith in what you're doing.