gpt4 book ai didi

Bash 脚本 - 意外的 token fi

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

所以我正在尝试编写一个 bash 脚本来说明:

如果文件 a 存在且目录 b 存在,则运行 composer install,检查 vendor 文件夹。如果我们找到它 - 回显并退出。

但它一直在说:

./composerrun.sh: line 6: syntax error near unexpected token `fi'
./composerrun.sh: line 6: ` fi'

而且我对 bash 太陌生了,无法理解这个右“大括号”是怎么错的:

#!/bin/bash
if checkForComposerJson && checkForAisisCore
composer install
if checkForVendor
echo "Found vendor"; exit;
fi
fi

function checkForAisisCore {
if [-d "AisisCore/"]
then
return 0;
else
echo "would you like us to create the directory?" yn,
case $yn in
Yes )
mkdir "AisisCore/";
if [-d "AisisCore/"]
return 0;;
else
echo "We could not create the directory as you requested";
return 1;;
end
No ) return 1;;
* ) echo "Please put in either yes or no";
esac
fi
}

function checkForVendor(){
if [-d "vender/adam.balan/aisis-core/"]
return 0;
else
"Something is wrong. We could not find the vendor/ folder. Please check that you are running this script inside of your theme or project folder.";
return 1;
fi
}

function checkForComposerJson(){
if [-f "composer.json"]
return 0;
else
echo "You need composer.json with appropriate information about AisisCore";
return 1;
fi
}

此外,我的 mkdir,如果目录不存在,我会在其中创建目录 - 我在单词后进行的检查 - 值得吗?

最佳答案

您忘记了一个then。应该是:

if checkForComposerJson && checkForAisisCore
then ## <-------------------
composer install
if checkForVendor
then ## <-------------------

echo "Found vendor"; exit;
fi
fi

关于Bash 脚本 - 意外的 token fi,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18924137/

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