V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
SmartDancer
V2EX  ›  问与答

请教一个 shell 问题

  •  
  •   SmartDancer · Apr 25, 2017 · 1873 views
    This topic created in 3296 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   ·   747 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 20:57 · PVG 04:57 · LAX 13:57 · JFK 16:57
    ♥ Do have faith in what you're doing.