aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Reed <m.reed@mykolab.com>2015-02-17 15:34:15 -0500
committerMichael Reed <m.reed@mykolab.com>2015-03-12 20:04:26 -0400
commit481ebc0bb11a46af080446d3b5f2a6bb45235c43 (patch)
treef1708a25b2748450eeeb17007792fb235f8e4ac0 /src
parent5fcd12f8b54afbf5675f164ca1ecf774adc3dad2 (diff)
downloadrneovim-481ebc0bb11a46af080446d3b5f2a6bb45235c43.tar.gz
rneovim-481ebc0bb11a46af080446d3b5f2a6bb45235c43.tar.bz2
rneovim-481ebc0bb11a46af080446d3b5f2a6bb45235c43.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/nvim/buffer.c2
-rw-r--r--src/nvim/ex_cmds.c6
-rw-r--r--src/nvim/ex_docmd.c4
-rw-r--r--src/nvim/globals.h2
-rw-r--r--src/nvim/main.c82
5 files changed, 13 insertions, 83 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index c4abcd77b1..c0b688e6ef 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -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 */
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index e98032da5c..a47b303a4a 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -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;
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 4e835cc43a..fa6021075d 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -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();
diff --git a/src/nvim/globals.h b/src/nvim/globals.h
index b15db61f99..d7087ee928 100644
--- a/src/nvim/globals.h
+++ b/src/nvim/globals.h
@@ -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
diff --git a/src/nvim/main.c b/src/nvim/main.c
index 897f251bb3..a4f430e811 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -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"));