Skip to content

Conversation

ZyX-I
Copy link
Contributor

@ZyX-I ZyX-I commented Mar 16, 2017

No description provided.

@marvim marvim added the RFC label Mar 16, 2017
end
neq(0, max_sec)
end)
it('does not expand $VAR', function()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is there because -S is not working well with such names (-S arg uses a concat of source and arg without any escaping used). -s is treated different and does not have the problem, but this option looks similar to -S.

@oni-link
Copy link
Contributor

With nvim -u NONE -s - and :qa I get this:

nvim: /home/oni-link/git/neovim/.deps/build/src/libuv/src/unix/core.c:521: uv__close: Assertion `fd > STDERR_FILENO' failed.
Aborted

@ZyX-I
Copy link
Contributor Author

ZyX-I commented Mar 19, 2017

@oni-link Interesting, I can reproduce this in tmux. I can’t reproduce it when running in Neovim terminal with exactly the same arguments (nvim_prog_abs(), '-u', 'NONE', '-i', 'NONE', '--cmd', 'set noswapfile shortmess+=IFW fileformats=unix', '-s', '-'). Note: it crashes on :, before I can type q.

Solution is obvious currently: use dup() to clone STDIN_FILENO and use the resulting fd. Though will need to use os/fileio.c in place of f* functions: fdopen is not in C99.

@ZyX-I
Copy link
Contributor Author

ZyX-I commented Mar 19, 2017

A bit different: I can reproduce this in termopen(), but either if I run it in an interactive shell or if I actually close inner Neovim, in the last case problem appears not when typing :, but during shutdown.

ZyX-I added 8 commits March 19, 2017 16:09
This variant uses `fdopen()` which is not standard, but it fixes problem on my 
system. In next commit `scriptin` will use `FileDescriptor*` from os/fileio in 
place of `FILE*`.
Problem: as fileio is cached and reads blocks this is going to wait
until either EOF or reading enough characters to fill rbuffer. This is
not good when reading user input from stdin as script.
@justinmk
Copy link
Member

Windows build hangs, termopen() won't work there, yet.

local attrs = lfs.attributes(fname)
eq(#('100500\n'), attrs.size)
end)
it('does not crash after reading from stdin in non-headless mode', function()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add

if helpers.pending_win32(pending) then return end

here, since this test uses termopen().

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

termopen() works on Windows now, so the above comment is outdated. Though reading from stdin on Windows may be broken (#6890) so maybe it's expedient to skip it for now.

@ZyX-I
Copy link
Contributor Author

ZyX-I commented Mar 23, 2017

It hangs on the very first test, and that does not use termopen(), it uses system().

ZyX-I added 2 commits March 23, 2017 21:04
Assume something with system() if second test hangs as well. Assume something 
with reading stdin if not.
@ZyX-I ZyX-I changed the title [RFC] Make -s - read from stdin [WIP] Make -s - read from stdin Apr 9, 2017
@marvim marvim removed the RFC label Apr 9, 2017
@marvim marvim added the WIP label Apr 9, 2017
ZyX-I added a commit to ZyX-I/neovim that referenced this pull request Jul 4, 2017
ZyX-I added a commit to ZyX-I/neovim that referenced this pull request Jul 4, 2017
/// @param[in] fd File descriptor to wrap.
/// @param[in] flags Flags, @see FileOpenFlags. Currently reading from and
/// writing to the file at once is not supported, so either
/// FILE_WRITE_ONLY or FILE_READ_ONLY is required.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be:

kFileWriteOnly or kFileReadOnly is required.

@@ -32,6 +33,8 @@ typedef enum {
///< kFileCreateOnly.
kFileAppend = 64, ///< Append to the file. Implies kFileWriteOnly. Cannot
///< be used with kFileCreateOnly.
kFileNonBlocking = 128, ///< Do not restart read() or write() syscall if
///< EAGAIN was encountered.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"EAGAIN or EINTR" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EAGAIN only.

@ZyX-I
Copy link
Contributor Author

ZyX-I commented Dec 3, 2017

Looks like

[ RUN      ] Command-line option -s does not expand $VAR: 

hang again.

@ZyX-I
Copy link
Contributor Author

ZyX-I commented Dec 3, 2017

If I recall correctly that is “using -s always hangs” rather then something specific to $fname.

@justinmk
Copy link
Member

justinmk commented Dec 3, 2017

Is it a regression or is it just a new test that can be skipped for now?

@ZyX-I
Copy link
Contributor Author

ZyX-I commented Dec 3, 2017

It is a new test, but I am not aware of the similar test that checked something before .

BTW, is there some script to build Neovim for wine? E.g. like I did for Vim once: https://bitbucket.org/ZyX_I/vim-dev-tools/src/342d10f67bbbb072288b80d0c7effb2507efe21b/winesetup.pl?at=default prepares WINEPREFIX (also builds Vim), specifically build.zsh near that uses mingw to build vim.

@justinmk
Copy link
Member

justinmk commented Dec 4, 2017

BTW, is there some script to build Neovim for wine?

Not that I know.

@ZyX-I
Copy link
Contributor Author

ZyX-I commented Dec 8, 2017

I started working on that, but soon found luarocks/luarocks#749. Most likely that means that quick “just make luarocks compile things for me” is out and all needed packages would be cross-compiled, or alternatives (like lullpeg) found, though I will try to determine why os.execute is incompatible on wine to that extent. Currently I can say that

luajit -e "print(os.execute(\"\\\"C:\\luarocks\\tools\\mkdir\\\" -p \\\"abc\\\"\"))"

fails, but succeeds without one pair of quotes. Reported two bugs to wine as a result: https://bugs.winehq.org/show_bug.cgi?id=44133 and https://bugs.winehq.org/show_bug.cgi?id=44132.

@janlazo
Copy link
Contributor

janlazo commented Dec 9, 2017

Is the following the intended command?

> "C:\luarocks\tools\mkdir\\" -p "abc"

Invoking cmd.exe (without explicit escaping) should be

cmd.exe /s/c ""C:\luarocks\tools\mkdir\\" -p "abc""

Seems to be a bug in os.execute if it's using /c

@justinmk
Copy link
Member

justinmk commented Dec 9, 2017

@ZyX-I If you have a RDP client you can connect to appveyor for 1-2 hours, useful for sanity checks. Requires a temporary change to appveyor.yml, a bit annoying but it works well. https://www.appveyor.com/docs/how-to/rdp-to-build-worker/

@justinmk justinmk mentioned this pull request Dec 10, 2017
@justinmk
Copy link
Member

After ignoring the "does not expand $VAR" test in #7713 now the "old tests" hang (since #7705 , the Vim "old tests" run on AppVeyor).

This hangs:

VIMRUNTIME=../../../runtime; export VIMRUNTIME;  ../../../build/bin/nvim.exe -u unix.vim -U NONE -i viminfo --headless --noplugin -s dotest.in test1.in

So there is a regression in the behavior of -s on Windows.

mch_errmsg("\"\n");
int error;
if (STRCMP(argv[0], "-") == 0) {
const int stdin_dup_fd = os_dup(OS_STDIN_FILENO);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ZyX-I maybe #8267 is helpful to implement os_dup on Windows.

end
end

describe('Command-line option', function()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could go in startup_spec.lua

@justinmk justinmk changed the title [WIP] Make -s - read from stdin Make -s - read from stdin Apr 16, 2018
@justinmk justinmk merged commit 78bc52e into neovim:master Apr 17, 2018
@justinmk justinmk removed the WIP label Apr 17, 2018
@ZyX-I ZyX-I deleted the s-dash-stdin branch May 1, 2018 17:45
@justinmk justinmk changed the title Make -s - read from stdin startup: Make "-s -" read from stdin May 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants