我们知道可以在bash中做以下几点:
curl -Ls example.com/script.sh | bash但我们能通过一些论据吗?
curl -Ls example.com/script.sh | bash --option1在这种情况下,bash将选择该选项。可以有什么方法把它传递给脚本吗?
发布于 2016-11-03 22:02:12
这就是-s选项的目的:
curl -Ls example.com/script.sh | bash -s -- --option1由于-s显式地告诉bash从标准输入读取其命令,所以它不尝试将其第一个参数解释为读取命令的文件。相反,所有参数都用于设置位置参数。
或者,您可以使用进程替换,而不是直接从标准输入读取。
bash <(curl -Ls example.com/script.sh) --option1发布于 2016-11-03 22:06:46
你可以这样做:
( echo 'set -- --option1' && curl -Ls example.com/script.sh ) | bash 若要在set命令前面添加输入,请执行以下操作。
https://stackoverflow.com/questions/40411939
复制相似问题