win/startup: remove --literal

Fixes 2 failing tests in startup_spec.lua.

The Windows-only `--literal` option complicates support of "stdin-as-text
+ file-args" (#7679).  Could work around it, but it's not worth
the trouble:
- users have a reasonable (and englightening) alternative: nvim +"n *"
- "always literal" is more consistent/predictable
- avoids platform-specific special-case

Unrelated changes:
- Replace fileno(stdxx) with STDXX_FILENO for consistency (not motivated
  by any observed technical reason).
This commit is contained in:
Justin M. Keyes 2018-05-29 07:22:15 +02:00
parent 4211255c75
commit 1f300e08b8
6 changed files with 24 additions and 61 deletions

View File

@ -73,19 +73,18 @@ See
Interpret all further arguments as files.
Can be used to edit files starting with a hyphen
.Pq Sq - .
.It Fl -literal
Interpret filenames literally, that is, do not expand wildcards.
Has no effect on Unix-like systems, where the shell expands wildcards.
.It Fl e
Ex mode.
Ex mode. Reads stdin as Ex commands.
See
.Ic :help Ex-mode .
.It Fl E
Ex mode, improved.
Ex mode, improved. Reads stdin as text.
See
.Ic :help gQ .
.It Fl es
Ex mode, silent.
Silent (batch) mode. Reads stdin as Ex commands.
.It Fl Es
Silent (batch) mode. Reads stdin as text.
.It Fl d
Diff mode.
Show the difference between two to four files, similar to

View File

@ -22,8 +22,7 @@ More generally, Vim is started with:
Option arguments and file name arguments can be mixed, and any number of them
can be given. However, watch out for options that take an argument.
Exactly one out of the following five items may be used to choose how to
start editing:
The following items may be used to choose how to start editing:
*-file* *---*
filename One or more file names. The first one will be the current
@ -34,7 +33,6 @@ filename One or more file names. The first one will be the current
nvim -- -filename
< All arguments after the "--" will be interpreted as file names,
no other options or "+command" argument can follow.
For behavior of quotes on MS-Windows, see |win32-quotes|.
*--*
- This argument can mean two things, depending on whether Ex
@ -104,13 +102,6 @@ argument.
(Only available when compiled with the |+startuptime|
feature).
*--literal*
--literal Take file names literally, don't expand wildcards. Not needed
for Unix, because Vim always takes file names literally (the
shell expands wildcards).
Applies to all the names, also the ones that come before this
argument.
*-+*
+[num] The cursor will be positioned on line "num" for the first
file being edited. If "num" is missing, the cursor will be

View File

@ -440,6 +440,10 @@ Other compile-time features:
Emacs tags support
X11 integration (see |x11-selection|)
Startup:
--literal (file args are always literal; to expand wildcards on Windows, use
|:n| e.g. `nvim +"n *"`)
Nvim does not have a built-in GUI and hence the following aliases have been
removed: gvim, gex, gview, rgvim, rgview

View File

@ -105,9 +105,6 @@ typedef struct {
int window_count; // number of windows to use
int window_layout; // 0, WIN_HOR, WIN_VER or WIN_TABS
#if !defined(UNIX)
int literal; // don't expand file names
#endif
int diff_mode; // start with 'diff' set
char *listen_addr; // --listen {address}
@ -299,15 +296,18 @@ int main(int argc, char **argv)
// Set the break level after the terminal is initialized.
debug_break_level = params.use_debug_break_level;
bool reading_excmds = exmode_active == EXMODE_NORMAL;
//
// Read user-input if any TTY is connected.
// Read ex-commands if invoked with "-es".
//
bool reading_input = !headless_mode
&& (params.input_isatty || params.output_isatty
|| params.err_isatty);
bool reading_excmds = exmode_active == EXMODE_NORMAL;
if (reading_input || reading_excmds) {
// One of the startup commands (arguments, sourced scripts or plugins) may
// prompt the user, so start reading from a tty now.
int fd = fileno(stdin);
int fd = STDIN_FILENO;
if (!reading_excmds
&& (!params.input_isatty || params.edit_type == EDIT_STDIN)) {
// Use stderr or stdout since stdin is being used to read commands.
@ -334,9 +334,7 @@ int main(int argc, char **argv)
// Reset 'loadplugins' for "-u NONE" before "--cmd" arguments.
// Allows for setting 'loadplugins' there.
if (params.use_vimrc != NULL && strequal(params.use_vimrc, "NONE")
// && !silent_mode // XXX: avoid hang with "nvim -es -u NONE".
) {
if (params.use_vimrc != NULL && strequal(params.use_vimrc, "NONE")) {
p_lpl = false;
}
@ -785,7 +783,6 @@ static void command_line_scan(mparm_T *parmp)
case '-': { // "--" don't take any more option arguments
// "--help" give help message
// "--version" give version message
// "--literal" take files literally
// "--noplugin[s]" skip plugins
// "--cmd <cmd>" execute cmd before vimrc
if (STRICMP(argv[0] + argv_idx, "help") == 0) {
@ -830,9 +827,7 @@ static void command_line_scan(mparm_T *parmp)
want_argument = true;
argv_idx += 6;
} else if (STRNICMP(argv[0] + argv_idx, "literal", 7) == 0) {
#if !defined(UNIX)
parmp->literal = true;
#endif
// Do nothing: file args are always literal. #7679
} else if (STRNICMP(argv[0] + argv_idx, "noplugin", 8) == 0) {
p_lpl = false;
} else if (STRNICMP(argv[0] + argv_idx, "cmd", 3) == 0) {
@ -1213,9 +1208,6 @@ scripterror:
int alist_fnum_flag = edit_stdin(had_stdin_file, parmp)
? 1 // add buffer nr after exp.
: 2; // add buffer number now and use curbuf
#if !defined(UNIX)
alist_fnum_flag = parmp->literal ? alist_fnum_flag : 0;
#endif
alist_add(&global_alist, p, alist_fnum_flag);
}
@ -1276,10 +1268,10 @@ static void init_startuptime(mparm_T *paramp)
static void check_and_set_isatty(mparm_T *paramp)
{
stdin_isatty
= paramp->input_isatty = os_isatty(fileno(stdin));
= paramp->input_isatty = os_isatty(STDIN_FILENO);
stdout_isatty
= paramp->output_isatty = os_isatty(fileno(stdout));
paramp->err_isatty = os_isatty(fileno(stderr));
= paramp->output_isatty = os_isatty(STDOUT_FILENO);
paramp->err_isatty = os_isatty(STDERR_FILENO);
#ifndef WIN32
int tty_fd = paramp->input_isatty
? STDIN_FILENO
@ -1315,26 +1307,6 @@ static void init_path(const char *exename)
/// Get filename from command line, if any.
static char_u *get_fname(mparm_T *parmp, char_u *cwd)
{
#if !defined(UNIX)
/*
* Expand wildcards in file names.
*/
if (!parmp->literal) {
cwd = xmalloc(MAXPATHL);
if (cwd != NULL) {
os_dirname(cwd, MAXPATHL);
}
// Temporarily add '(' and ')' to 'isfname'. These are valid
// filename characters but are excluded from 'isfname' to make
// "gf" work on a file name in parenthesis (e.g.: see vim.h).
do_cmdline_cmd(":set isf+=(,)");
alist_expand(NULL, 0);
do_cmdline_cmd(":set isf&");
if (cwd != NULL) {
os_chdir((char *)cwd);
}
}
#endif
return alist_name(&GARGLIST[0]);
}
@ -1947,9 +1919,6 @@ static void usage(void)
mch_msg(_(" --embed Use stdin/stdout as a msgpack-rpc channel\n"));
mch_msg(_(" --headless Don't start a user interface\n"));
mch_msg(_(" --listen <address> Serve RPC API from this address\n"));
#if !defined(UNIX)
mch_msg(_(" --literal Don't expand wildcards\n"));
#endif
mch_msg(_(" --noplugin Don't load plugins\n"));
mch_msg(_(" --startuptime <file> Write startup timing messages to <file>\n"));
mch_msg(_("\nSee \":help startup-options\" for all options.\n"));

View File

@ -50,7 +50,7 @@ void input_init(void)
input_buffer = rbuffer_new(INPUT_BUFFER_SIZE + MAX_KEY_CODE_LEN);
}
/// File (set at startup) used to read user-input (or commands for -e/-es).
/// This is the global stream of user-input (or Ex-commands for "-es").
int input_global_fd(void)
{
return global_fd;

View File

@ -108,7 +108,7 @@ describe('startup', function()
|
]])
end)
it('input from pipe (implicit) + file args #7679', function()
it('input from pipe + file args #7679', function()
eq('ohyeah\r\n0 0 bufs=3',
funcs.system({nvim_prog, '-n', '-u', 'NONE', '-i', 'NONE', '--headless',
'+.print',
@ -121,7 +121,7 @@ describe('startup', function()
{ 'ohyeah', '' }))
end)
it('stdin with -es, -Es #7679', function()
it('stdin with -es/-Es #7679', function()
local input = { 'append', 'line1', 'line2', '.', '%print', '' }
local inputstr = table.concat(input, '\n')