使用 sudo 时未设置 SVN_EDITOR
我需要使用 sudo 在我的项目上运行 svn 命令。我在自己的 .bash_profile 以及 root 用户的 .bash_profile 中将 SVN_EDITOR 设置为 vi,但是当我尝试执行 svn propedit 时,我得到
svn:未设置任何环境变量 SVN_EDITOR、VISUAL 或 EDITOR,并且未找到“editor-cmd”运行时配置选项
每次启动新会话时,我都必须设置 SVN_EDITOR。这是一种痛苦。关于如何/在哪里永久设置 SVN_EDITOR 有什么建议吗?这是在 CentOS 5.4 上。
I need to use sudo to run svn commands on my project. I have the SVN_EDITOR set to be vi in my own .bash_profile as well as in the root user's .bash_profile, but when I try to do an svn propedit, I get
svn: None of the environment variables SVN_EDITOR, VISUAL or EDITOR is set, and no 'editor-cmd' run-time configuration option was found
Each time I start a new session, I have to set the SVN_EDITOR. This is a pain. Any suggestions on how/where I can set SVN_EDITOR permanently? This is on CentOS 5.4.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
通过 sudo 运行命令不会启动登录或“交互式”shell,因此将其添加到各种 bashrc 或 profile 资源文件中不会有帮助。
正如 DES 所说,快速而肮脏的方法是:
但正如 derobert 评论的那样,更好、更永久的解决方案是运行
sudo visudo
来编辑 /etc/sudoers ,并添加 < code>SVN_EDITOR 到 env_keep 选项。Running commands through sudo doesn't start a login or "interactive" shell so adding it to various bashrc or profile resource files won't help.
As DES said, the quick and dirty way is:
But as derobert commented, the better more permanent solution is to run
sudo visudo
to edit /etc/sudoers , and addSVN_EDITOR
to the env_keep option.sudo
在运行命令之前会清理大部分环境。这是一件好事™。快速而肮脏的解决方法是使用env
:在
~root/.bashrc
中定义SVN_EDITOR
应该可以,但更好的解决方案是在/etc/profile
中定义它,以便每个用户获得相同的值。sudo
cleans out most of your environment before running the command. This is a Good Thing™. The quick-and-dirty workaround is to useenv
:Defining
SVN_EDITOR
in~root/.bashrc
should work, but a better solution is to define it in/etc/profile
so every user gets the same value.~/.bashrc
我记得 .bash_profile 在连接时被调用。 (当您 ssh 到机器时)并且每个 bash 进程启动都会调用 .bashrc 。但我可以把这个倒过来。
Centos 是当今少数严格遵守这一点的发行版之一。据我所知。
~/.bashrc
As I recall .bash_profile is called on connection. (when you ssh to the machine) and .bashrc is called for each bash proccess start. But I could have this backwards.
Centos is one of the few distros that honor this rigorously these days. To my knowledge.