bash 将 sudo 标志传递到 makefile 中
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22633783/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Passing sudo flags into makefile
提问by Douglas Kastle
I am currently located behind a proxy. Sitting in the land of bash, I have my HTTP_PROXY and HTTPS_PROXY set as environment variables set to the proxy. When I want to install something under sudo, like pip, I have to use the -E flag with sudo to get the install to work:
我目前位于代理后面。坐在 bash 的土地上,我将 HTTP_PROXY 和 HTTPS_PROXY 设置为设置为代理的环境变量。当我想在 sudo 下安装某些东西时,比如 pip,我必须在 sudo 中使用 -E 标志才能使安装工作:
sudo -E pip install 'selenium>=2.40.0'
That is fine and works.
那很好并且有效。
However I have some across a Makefile that calls sudo pip install. Even if I call make with the -E flag
但是,我在调用 sudo pip install 的 Makefile 中有一些。即使我用 -E 标志调用 make
sudo -E make install
The -E flag from sudo is no picked up in the Makefile when the makefile tries to do an installation from pip (that I am using)
当 makefile 尝试从 pip(我正在使用)进行安装时,来自 sudo 的 -E 标志不会在 Makefile 中被拾取
Is is possible for a Makefile to pick up the flags used when calling the sudo command?
Makefile 是否可以选择调用 sudo 命令时使用的标志?
回答by Aaron Hanson
before calling any makefile that has 'sudo pip install', you could set an alias for sudo . Ex:
在调用任何具有 'sudo pip install' 的 makefile 之前,您可以为 sudo 设置一个别名。前任:
alias sudo='sudo -E'
make install
To remove the alias for the rest of the process;
删除其余过程的别名;
unalias sudo
(you can, of course, skip the unalias if you want it to persist for the duration of the process)
(当然,如果您希望它在整个过程中持续存在,您可以跳过 unalias)