小编Ant*_*ioD的帖子

什么是":?" 这个shell命令意味着什么?

这是shell脚本:

#!/bin/bash

version="0.01";

fibonacci() {
    n=${1:?If you want the nth fibonacci number, you must supply n as the first parameter.}
    if [ $n -le 1 ]; then 
    echo $n
    else
    l=`fibonacci $((n-1))`
    r=`fibonacci $((n-2))`
    echo $((l + r))
    fi
}

for i in `seq 1 10`
do
  result=$(fibonacci $i)
  echo "i=$i result=$result"
done
Run Code Online (Sandbox Code Playgroud)

我对这一行感到困惑:

n=${1:?If you want the nth fibonacci number, you must supply n as the first parameter.}
Run Code Online (Sandbox Code Playgroud)

我寻找shell的手册,但什么都没有得到":?" 实际上意思是

谢谢

linux bash shell

0
推荐指数
1
解决办法
230
查看次数

标签 统计

bash ×1

linux ×1

shell ×1