Skip to content
forked from neovim/neovim

Commit

Permalink
win/startup: remove --literal
Browse files Browse the repository at this point in the history
Fixes 2 failing tests in startup_spec.lua.

The Windows-only `--literal` option complicates support of "stdin-as-text
+ file-args" (neovim#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).
  • Loading branch information
justinmk committed May 29, 2018
1 parent e1f7a67 commit 6bf6492
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 50 deletions.
11 changes: 5 additions & 6 deletions man/nvim.1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 0 additions & 7 deletions runtime/doc/starting.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,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
Expand Down
4 changes: 4 additions & 0 deletions runtime/doc/vim_diff.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
43 changes: 6 additions & 37 deletions src/nvim/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -300,14 +297,15 @@ int main(int argc, char **argv)
debug_break_level = params.use_debug_break_level;

bool reading_excmds = exmode_active == EXMODE_NORMAL;
// Read input if any TTY is connected or if invoked with "-es".
bool reading_input = !headless_mode
&& (params.input_isatty || params.output_isatty
|| params.err_isatty);

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.
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -1213,9 +1208,6 @@ static void command_line_scan(mparm_T *parmp)
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);
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]);
}

Expand Down Expand Up @@ -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"));
Expand Down

0 comments on commit 6bf6492

Please sign in to comment.