xing393939
V2EX  ›  Node.js

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

  •  
  •   xing393939 · Jan 13, 2017 · 2390 views
    This topic created in 3584 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
    magicdawn
    Jan 13, 2017
    1
    DEBUG=mydebug:* echo ${DEBUG}

    解析 DEBUG=空

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

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