小编Oğu*_*ğuz的帖子

Bash 脚本函数返回真假

我想通过返回值来查询函数。我的代码如下;

check(){
    file=/root/Turkiye.txt
    local funkx=$1
    while read line; do
        if [ "$line" == "$funkx" ]
        then
            true
            break
        else
            false
        fi
    done < $file
}

printf "Please enter the value : "
read keyboard

if check $keyboard;
then
    echo "yes";
else
    echo "no";
fi
Run Code Online (Sandbox Code Playgroud)

它不起作用,我做错了什么?

shell-script function exit-status

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

exit-status ×1

function ×1

shell-script ×1