SmartDancer
V2EX  ›  问与答

请教一个 shell 问题

  •  
  •   SmartDancer · Apr 25, 2017 · 1950 views
    This topic created in 3330 days ago, the information mentioned may be changed or developed.
    为何当变量 var 为空时,命令 [ -e $var ] 状态码是 0 ?
    thanks
    SoloCompany
        1
    SoloCompany  
       Apr 26, 2017
    加引号

    http://www.gnu.org/software/bash/manual/html_node/Bourne-Shell-Builtins.html#index-test

    The test and [ builtins evaluate conditional expressions using a set of rules based on the number of arguments.

    0 arguments
    The expression is false.

    1 argument
    The expression is true if and only if the argument is not null.
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    SmartDancer
        2
    SmartDancer  
    OP
       Apr 26, 2017 via Android
    @SoloCompany thank you! 请教一下这个问题如何 google 关键词!
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4002 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 05:11 · PVG 13:11 · LAX 22:11 · JFK 01:11
    ♥ Do have faith in what you're doing.