这个shell脚本有什么作用?

时间:2017-02-06 21:19:50

标签: shell scripting

FROM_PROJECT=false
if [[ -z $INV_NAME ]]; then
    if [[ -z $PRO_NAME ]]; then
            echo "error: variable not set" >&2
            exit 1
    elif [[ -z $INV_FILE ]]; then
            echo "error: variable INV not set" >&2
            exit 1
    fi
    FROM_PRO=true
elif [[ -n $PRO_NAME ]] || [[ -n $INV_FILE ]]; then
    echo "error: variable INV_NAME is not compatible with PRO_NAME and             INVENTORY_FILE" >&2
    exit 1

我不确定这些" -z"和" -n"在这做什么?

1 个答案:

答案 0 :(得分:2)

-z用于测试字符串是否为空。

-n恰恰相反。

相关问题