嗨,我正在尝试在 shell 脚本中运行 bash 命令,但由于我对 Linux/Unix 的了解非常少,无法完全弄清楚如何。
这是命令:
bash <(curl -s https://raw.githubusercontent.com/TitouanVanBelle/XCTestHTMLReport/master/install.sh) '1.0.0'
我可以在没有这样的版本的情况下在 shell 中执行命令:
/bin/bash -c "$(curl -s https://raw.githubusercontent.com/TitouanVanBelle/XCTestHTMLReport/master/install.sh)"
但是如果我尝试像这样传递版本:
/bin/bash -c "$(curl -s https://raw.githubusercontent.com/TitouanVanBelle/XCTestHTMLReport/master/install.sh) '1.0.0'"
或
/bin/bash -c "$(curl -s https://raw.githubusercontent.com/TitouanVanBelle/XCTestHTMLReport/master/install.sh '1.0.0')"
它不会执行命令。有人可以帮我吗
答案 0 :(得分:0)
这个命令会做同样的事情,试试这个-
curl -s https://raw.githubusercontent.com/TitouanVanBelle/XCTestHTMLReport/master/install.sh | bash -s '1.0.0'
curl 从网上下载 this 脚本,下载完成后文件将由 bash 运行,bash 会将参数“1.0.0”传递给它以下载此特定版本的 XCTestHTMLReport(默认为到版本 1.6.1)。
或者您可以简单地在您的计算机上创建一个脚本文件,然后运行它来做同样的事情。
#!/bin/bash
set -e
VERSION=$1
if [ -z $VERSION ] ; then
VERSION="1.0.0"
fi
OUT_ZIP="xchtmlreport.zip"
printf "Downloading xchtmlreport $VERSION\n"
CURL=$(curl -L -s -w "%{http_code}" -o $OUT_ZIP https://github.com/TitouanVanBelle/XCTestHTMLReport/releases/download/$VERSION/xchtmlreport-$VERSION.zip)
if [ ! -f $OUT_PATH ]; then
printf '\e[1;31m%-6s\e[m' "Failed to download XCTestHTMLReport. Make sure the version you're trying to download exists."
printf '\n'
exit 1
fi
unzip $OUT_ZIP
chmod 755 xchtmlreport
mv xchtmlreport /usr/local/bin/
rm $OUT_ZIP
printf '\e[1;32m%-6s\e[m' "Successully installed XCTestHTMLReport. Execute xchtmlreport -h for help."
printf '\n'
exit 0
我做了一点修改,因为我将默认版本更改为 1.0.0。