SmartDancer
V2EX  ›  问与答

请教一个 shell 问题

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

    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
    SmartDancer
    OP
    Apr 26, 2017 via Android
    2
    @SoloCompany thank you! 请教一下这个问题如何 google 关键词!
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1532 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 23:35 · PVG 07:35 · LAX 15:35 · JFK 18:35
    ♥ Do have faith in what you're doing.