bash - If-Statement 疯了(还是我?)
问题描述
这是我的 bash 脚本的参数之一。但似乎有什么不对劲。
bash 脚本:
case "${1}" in
--api )
if ( "${2}" == "US" ); then
sparkEndpoint="https://api.sparkpost.com/api/v1/transmissions"
shift
elif ( "${2}" == "EU" ); then
sparkEndpoint="https://api.eu.sparkpost.com/api/v1/transmissions"
shift
else
echo -e ${parameterNotSpecified}
echo -e ${usageApi}
break
fi
shift
;; [...]
控制台输出:
./fn_sendmail.sh --api EU
./fn_sendmail.sh: Zeile 95: EU: Kommando nicht gefunden.
./fn_sendmail.sh: Zeile 98: EU: Kommando nicht gefunden.
You called an option but didn't specified it! Usage of --api
--api [eu,us]
Description: Sets the API endpoint for Sparkpost
Necessary: No
Default: EU
解决方案
你可能需要
shift 2
删除 the--api
和location (US/EU)。
推荐阅读
- python - Python 和模块有不同的路径
- python - 检测大图像中的小图像
- python - python中需要相互获取信息的函数
- django - Django 管理员在末尾显示带有额外“s”的模型名称
- r - 如何在R中的箱线图中添加连接点的线?
- c# - 读取 XML 文件,然后按名称按字母顺序排序
- c++ - v8::Value::ToString':没有重载函数接受 0 个参数
- javascript - 相同的端点,由 axios 和 fetch 打包的响应不同。如何转换?
- sorting - 在 Dask Dataframe 中滞后值的最佳方法是什么?
- godot - Godot 3.3.2 - 从父级更改子变量而不重置它们