Interface cleanup: Symlink handling & docs

This removes the ability to start nvim via the following aliases in
favor of just using their command line arguments:

ex        vim -e
exim      vim -E
view      vim -R
gvim      vim -g
gex       vim -eg
gview     vim -Rg
rvim      vim -Z
rview     vim -RZ
rgvim     vim -gZ
rgview    vim -RgZ

This also removes Vi mode (-v) for consistency. From ':help -v':

    -v  Start Ex in Vi mode.  Only makes a difference when the
    executable is called "ex" or "gvim".  For gvim the GUI is not
    started if possible.
This commit is contained in:
Michael Reed
2015-02-17 15:34:15 -05:00
parent 5fcd12f8b5
commit 481ebc0bb1
11 changed files with 36 additions and 172 deletions

View File

@@ -213,7 +213,7 @@ open_buffer (
* So the modelines have priority over auto commands.
*/
/* When reading stdin, the buffer contents always needs writing, so set
* the changed flag. Unless in readonly mode: "ls | gview -".
* the changed flag. Unless in readonly mode: "ls | nvim -R -".
* When interrupted and 'cpoptions' contains 'i' set changed flag. */
if ((got_int && vim_strchr(p_cpo, CPO_INTMOD) != NULL)
|| modified_was_set /* ":set modified" used in autocmd */

View File

@@ -853,7 +853,7 @@ void do_bang(int addr_count, exarg_T *eap, int forceit, int do_in, int do_out)
int scroll_save = msg_scroll;
/*
* Disallow shell commands for "rvim".
* Disallow shell commands in restricted mode (-Z)
* Disallow shell commands from .exrc and .vimrc in current directory for
* security reasons.
*/
@@ -1217,7 +1217,7 @@ do_shell (
int save_nwr;
/*
* Disallow shell commands for "rvim".
* Disallow shell commands in restricted mode (-Z)
* Disallow shell commands from .exrc and .vimrc in current directory for
* security reasons.
*/
@@ -3378,7 +3378,7 @@ void ex_z(exarg_T *eap)
int check_restricted(void)
{
if (restricted) {
EMSG(_("E145: Shell commands not allowed in rvim"));
EMSG(_("E145: Shell commands not allowed in restricted mode"));
return TRUE;
}
return FALSE;

View File

@@ -5375,9 +5375,7 @@ static void ex_hide(exarg_T *eap)
*/
static void ex_stop(exarg_T *eap)
{
/*
* Disallow suspending for "rvim".
*/
// Disallow suspending in restricted mode (-Z)
if (!check_restricted()) {
if (!eap->forceit) {
autowrite_all();

View File

@@ -601,7 +601,7 @@ EXTERN volatile int full_screen INIT(= FALSE);
* otherwise only writing some messages */
EXTERN int restricted INIT(= FALSE);
/* TRUE when started as "rvim" */
// TRUE when started in restricted mode (-Z)
EXTERN int secure INIT(= FALSE);
/* non-zero when only "safe" commands are
* allowed, e.g. when sourcing .exrc or .vimrc

View File

@@ -204,11 +204,9 @@ int main(int argc, char **argv)
// Check if we have an interactive window.
check_and_set_isatty(&params);
/*
* Figure out the way to work from the command name argv[0].
* "view" sets "readonlymode", "rvim" sets "restricted", etc.
*/
parse_command_name(&params);
// Get the name with which Nvim was invoked, with and without path.
set_vim_var_string(VV_PROGPATH, (char_u *)argv[0], -1);
set_vim_var_string(VV_PROGNAME, path_tail((char_u *)argv[0]), -1);
/*
* Process the command line arguments. File names are put in the global
@@ -820,69 +818,8 @@ static void init_locale(void)
}
TIME_MSG("locale set");
}
#endif
/*
* Check for: [r][g][vi|vim|view][ex[im]]
* If the executable name starts with "r" we disable shell commands.
* If the next character is "g" we run the GUI version.
* If the next characters are "view" we start in readonly mode.
* If the next characters are "ex" we start in Ex mode. If it's followed
* by "im" use improved Ex mode.
*/
static void parse_command_name(mparm_T *parmp)
{
char_u *initstr;
initstr = path_tail((char_u *)parmp->argv[0]);
set_vim_var_string(VV_PROGNAME, initstr, -1);
set_vim_var_string(VV_PROGPATH, (char_u *)parmp->argv[0], -1);
if (parse_string(&initstr, "editor", 6))
return;
if (parse_char_i(&initstr, 'r'))
restricted = TRUE;
/* "gvim" starts the GUI. Also accept "Gvim" for MS-Windows. */
if (parse_char_i(&initstr, 'g'))
main_start_gui();
if (parse_string(&initstr, "view", 4)) {
readonlymode = TRUE;
curbuf->b_p_ro = TRUE;
p_uc = 10000; /* don't update very often */
} else {
parse_string(&initstr, "vim", 3); /* consume "vim" if it's there */
}
if (parse_string(&initstr, "ex", 2)) {
if (parse_string(&initstr, "im", 2))
exmode_active = EXMODE_VIM;
else
exmode_active = EXMODE_NORMAL;
}
}
static bool parse_char_i(char_u **input, char val)
{
if (TOLOWER_ASC(**input) == val) {
*input += 1; /* or (*input)++ WITH parens */
return true;
}
return false;
}
static bool parse_string(char_u **input, char *val, int len)
{
if (STRNICMP(*input, val, len) == 0) {
*input += len;
return true;
}
return false;
}
/*
* Scan the command line arguments.
@@ -1134,10 +1071,6 @@ static void command_line_scan(mparm_T *parmp)
}
break;
case 'v': /* "-v" Vi-mode (as if called "vi") */
exmode_active = 0;
break;
case 'w': /* "-w{number}" set window height */
/* "-w {scriptout}" write to script */
if (vim_isdigit(((char_u *)argv[0])[argv_idx])) {
@@ -2034,13 +1967,12 @@ static void usage(void)
#if !defined(UNIX)
mch_msg(_(" --literal Don't expand wildcards\n"));
#endif
mch_msg(_(" -v Vi mode (like \"vi\")\n"));
mch_msg(_(" -e Ex mode (like \"ex\")\n"));
mch_msg(_(" -e Ex mode\n"));
mch_msg(_(" -E Improved Ex mode\n"));
mch_msg(_(" -s Silent (batch) mode (only for \"ex\")\n"));
mch_msg(_(" -s Silent (batch) mode (only for ex mode)\n"));
mch_msg(_(" -d Diff mode\n"));
mch_msg(_(" -R Readonly mode (like \"view\")\n"));
mch_msg(_(" -Z Restricted mode (like \"rvim\")\n"));
mch_msg(_(" -R Readonly mode\n"));
mch_msg(_(" -Z Restricted mode\n"));
mch_msg(_(" -m Modifications (writing files) not allowed\n"));
mch_msg(_(" -M Modifications in text not allowed\n"));
mch_msg(_(" -b Binary mode\n"));