直接下载脚本您无需克隆存储库即可运行脚本.直接下载就行了:curl -o gid https://raw.githubusercontent.com/jamesqo/gid/master/gid现在它已作为 gid 下载,您可以将其作为 Bash 脚本运行,例如,bash gid --help您还可以使下载的脚本可执行,以便将其作为常规 Unix 脚本文件运行(使用它的 shebang,#!/bin/bash):chmod +x gid./gid --help使用进程替换如果您想运行脚本而不实际将其保存到文件中,您可以使用 Bash 进程替换:bash <(curl -sSL https://github.com/jamesqo/gid/raw/master/gid) --helpI'm testing a Bash script I created on GitHub for behavioral correctness (e.g. that it parses options correctly). I want to do this without having to clone the repository locally, so here is how I'm doing it:curl -sSL https://github.com/jamesqo/gid/raw/master/gid | xargs -0 bash -cMy question is, how can I pass arguments to the script in question? I tried bash -c --help, but that didn't work since it got interpreted as part of the script.Thanks! 解决方案 You’re actually over-complicating things by using xargs with Bash’s -c option.Download the script directlyYou don’t need to clone the repository to run the script. Just download it directly:curl -o gid https://raw.githubusercontent.com/jamesqo/gid/master/gidNow that it’s downloaded as gid, you can run it as a Bash script, e.g.,bash gid --helpYou can also make the downloaded script executable in order to run it as a regular Unix script file (using its shebang, #!/bin/bash):chmod +x gid./gid --helpUse process substitutionIf you wanted to run the script without actually saving it to a file, you could use Bash process substitution:bash <(curl -sSL https://github.com/jamesqo/gid/raw/master/gid) --help 这篇关于将参数传递给使用 bash -c 调用的脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-18 10:32