while inside if construct doesn't produce results

问题描述 投票:0回答:0

我想知道为什么我的 while 构造没有被处理或者为什么在提供参数时它不产生任何输出

dirs2 () {
stack=($(dirs))


if [[ $# -eq 0  ]]; then

echo $stack

else 

        while getopts ":n:l" opt; do
                case $opt in
                        l ) echo $stack | sed -E 's/\~/home\/maciek/g';;
                        n ) echo "dudud";;
                        \? ) echo  "use correct arguments" 
                esac    
        done
fi

}
bash if-statement while-loop getopts
© www.soinside.com 2019 - 2024. All rights reserved.