hel*_*hod 5 parameters bash idioms command-line-arguments conditional-statements
如果没有给出位置参数,在 Bash 中测试最惯用的方法是什么?有很多方法可以检查这一点,我想知道是否有一种首选方法。
一些方法是:
((! $# )) # check if $# is 'not true'
(($# == 0)) # $# is 0
[[ ! $@ ]] # $@ is unset or null
Run Code Online (Sandbox Code Playgroud)
小智 8
对我来说,经典的方式是:
[[ $# -eq 0 ]]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4196 次 |
| 最近记录: |