使用 sudo 时未设置 SVN_EDITOR

发布于 2024-10-08 19:48:22 字数 308 浏览 5 评论 0原文

我需要使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

陪你搞怪i 2024-10-15 19:48:22

通过 sudo 运行命令不会启动登录或“交互式”shell,因此将其添加到各种 bashrcprofile 资源文件中不会有帮助。

正如 DES 所说,快速而肮脏的方法是:

sudo env "SVN_EDITOR=$SVN_EDITOR" svn propedit svn:ignore .

但正如 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:

sudo env "SVN_EDITOR=$SVN_EDITOR" svn propedit svn:ignore .

But as derobert commented, the better more permanent solution is to run sudo visudo to edit /etc/sudoers , and add SVN_EDITOR to the env_keep option.

眼泪也成诗 2024-10-15 19:48:22

sudo 在运行命令之前会清理大部分环境。这是一件好事™。快速而肮脏的解决方法是使用 env

sudo env SVN_EDITOR=$SVN_EDITOR svn propedit svn:ignore .

~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 use env:

sudo env SVN_EDITOR=$SVN_EDITOR svn propedit svn:ignore .

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.

独留℉清风醉 2024-10-15 19:48:22

~/.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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文