vi run as root gives error accessing .exrc

今天有用户在使用某个内部工具时遇到这样一个问题:

Not owner of .exrc or .exrc is group or world writable
Error detected in .exrc.[Hit return to continue]

他说这个问题只在某些server上存在,大多数server上不会遇到。上穷碧落下黄泉地在公司内部搜索了一遍,没发现有用的信息。
郁闷中想起Google,于是试了一下,结果却是大喜过望,原来这是一个常见的vi引起的问题。
http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=4938594有详细的解释,转载如下:
Description
If a user has a $HOME/.exrc file, and runs vi while su'ed to root,
the error:

Not owner of .exrc or .exrc is group or world writable
Error detected in .exrc.[Hit return to continue]
Work Around
set the EXINIT environment variable.  Please search the vi man pages for "EXINIT" for infomation on this.

Here's is what I added to my .cshrc file:
setenv EXINIT 'set tabstop=4 wrapscan nomesg | map @4 :set tabstop=4^M |
map @8 :set tabstop=8^M | map @L :set list^M | map @l :set nolist^M |
map @n :w/!^M:n^M | map @N :n^M | map @r :w/!^M:rewind^M|map @R
:rewind/!^M |
map @W :w/!^M^Z | map @D Oopen(DB,">>/tmp/dbgdrc");^Mprint DB
"/n";^Mclose(DB);^['

NOTES:
1) ^M is a ctrl-M (entered as ctrl-v ctrl-m) and ^[ is an escape
character (ctrl-v Esc).
2) The '!' has to be escaped with the backslash to prevent it being
interpreted by the shell.
3) Everything between the single quotes is on a single line. It is
broken here for readability.
4) Rename/delete the .exrc file or you'll get the same error as before.

 [email protected] 2004-12-10 23:57:36 GMT
Comments
N/A

To avoid error "Not owner of .exrc or .exrc is group or world writable" in vi-- Posted by inturi on Wednesday, January 23 2008
set this environment variable
export EXINIT="set noexrc"

你可能感兴趣的:(Access)