linux - Bash语法中的`-z`是什么意思?
迷茫
迷茫 2017-04-17 15:46:53
0
2
1159

尝试模仿spf13-vim.sh这个脚本写一个脚本时;看到其中有如下代码片段:

############################  SETUP PARAMETERS
app_name='spf13-vim'
[ -z "$APP_PATH" ] && APP_PATH="$HOME/.spf13-vim-3"
[ -z "$REPO_URI" ] && REPO_URI='https://github.com/spf13/spf13-vim.git'
[ -z "$REPO_BRANCH" ] && REPO_BRANCH='3.0'
debug_mode='0'
fork_maintainer='0'
[ -z "$VUNDLE_URI" ] && VUNDLE_URI="https://github.com/gmarik/vundle.git"

看到其中[ -z "$APP_PATH" ] && APP_PATH="$HOME/.spf13-vim-3"类似这句话,google查阅理解如下:
如果不存在APP_PATH这个变量,就把APP_PATH的值设置为"$HOME/.spf13-vim-3"。不知道是不是正确的?
-z这个变量我google搜索没有找到我需要的结果相关结果(亦或者有相关搜索方法吗?)


分割线

如果要知道这个命令的含义,直接在Terminal输入man [就可以看到帮助了,感谢@
springhack 的回答。

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(2)
小葫芦

First of all, you should check the help of [command;
Secondly, it is used to determine whether the string length is 0 (Zero)

迷茫

That’s a judgment expression, there are several ways to write it

It is recommended to go through the shell syntax systematically first

Shell has a lot of pitfalls, otherwise if you imitate it like this, the shell you write in the future will have problems

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!