gpt4 book ai didi

bash - 测试是否没有给出位置参数的惯用方法?

转载 作者:行者123 更新时间:2023-11-29 09:11:31 24 4
gpt4 key购买 nike

如果没有给出位置参数,Bash 中最惯用的测试方法是什么?有很多方法可以检查这个,我想知道是否有一种首选方法。

一些方式是:

((! $# )) # check if $# is 'not true'
(($# == 0)) # $# is 0
[[ ! $@ ]] # $@ is unset or null

最佳答案

对我来说,经典的方式是:

[[ $# -eq 0 ]]

关于bash - 测试是否没有给出位置参数的惯用方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11492338/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com