0

my vimrc seems to not play along with vipw/vigr (probably because i only allow root to place tmp/buffers/etc in a secure location) so I tried (using bash):

user@host$ EDITOR='/usr/bin/vim -u NONE' vigr

But I still get my vimrc setup... what's the correct way to set the editor variable for a one-off run of vipw/vigr?

2 Answers 2

1

Use a wrapper script:

echo $'#! /bin/sh\n/usr/bin/vim -u NONE' >~/vim_without_vimrc.sh
chmod 755 ~/vim_without_vimrc.sh
EDITOR=~/vim_without_vimrc.sh
vigr
0

Possibly you have $VISUAL set to vim as well, and vipw/vigr (at least the ones in the passwd package on Debian) uses that instead of $EDITOR if both are set (like most applications do), so:

VISUAL='vim -u NONE' vigr

Should do it as long as your vipw/vigr like Debian's expects that to be sh code (runs sh -c -- <that-code-concatenated-with-" /etc/group.edit">) instead of the name or path of an editor executable (to call with /etc/group.edit as argument)¹.

From the Debian man page for vipw/vigr:

When looking for an editor, the programs will first try the environment variable $VISUAL, then the environment variable $EDITOR, and finally the default editor, vi(1).


¹ Most of the time, $VISUAL/$EDITOR are intended as code passed to sh (that's what Debian's environ(7) man page specifies). In my experience, other possibilities are code passed to $SHELL (see also less which upon v runs sh (possibly via system(3)) to run $SHELL to interpret the code), or the program will do a shell-like tokenising of it, skipping the call to a shell and avoid doing other forms of shell expansions/interpretation, or expect the name or path of an editor only and don't run any shell (for mailx, POSIX specifies $EDITOR is meant to be an editor name, and $VISUAL an editor pathname, I doubt many implementations honour that).

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.