Skip to content

Conversation

janlazo
Copy link
Contributor

@janlazo janlazo commented Oct 6, 2018

vim-patch:8.0.1807: function to set terminal name is too long

Problem: Function to set terminal name is too long.
Solution: Refactor the function. Fix typo in test.
vim/vim@69e0569

vim-patch:8.1.0453: MS-Windows: executable() is not reliable

Problem: MS-Windows: executable() is not reliable.
Solution: Use $PATHEXT properly. (Yasuhiro Matsumoto, closes vim/vim#3412)
vim/vim@8295666

vim-patch:8.1.0454: resolve() was not tested with a symlink cycle

Problem: resolve() was not tested with a symlink cycle.
Solution: Add a test. (Dominique Pelle, closes vim/vim#3513)
vim/vim@2610990

@marvim marvim added the vim-patch See https://neovim.io/doc/user/dev_vimpatch.html label Oct 6, 2018
Problem:    Function to set terminal name is too long.
Solution:   Refactor the function.  Fix typo in test.
vim/vim@69e0569
Problem:    resolve() was not tested with a symlink cycle.
Solution:   Add a test. (Dominique Pelle, closes vim/vim#3513)
vim/vim@2610990
@janlazo janlazo changed the title vim-patch:8.0.1807 vim-patch:8.0.1807,8.1.0454 Oct 6, 2018
Problem:    MS-Windows: executable() is not reliable.
Solution:   Use $PATHEXT properly. (Yasuhiro Matsumoto, closes vim/vim#3412)
vim/vim@8295666
@janlazo janlazo changed the title vim-patch:8.0.1807,8.1.0454 vim-patch:8.0.1807,8.1.{453,454} Oct 7, 2018
@janlazo janlazo changed the title vim-patch:8.0.1807,8.1.{453,454} [RFC] vim-patch:8.0.1807,8.1.{453,454} Oct 7, 2018
@marvim marvim added the RFC label Oct 7, 2018
call assert_equal(1, executable('notepad.exe'))
call assert_equal(0, executable('notepad.exe.exe'))
call assert_equal(0, executable('shell32.dll'))
call assert_equal(0, executable('win.ini'))
Copy link
Contributor Author

@janlazo janlazo Oct 7, 2018

Choose a reason for hiding this comment

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

Why are these not executable? dll and ini don't open notepad? As for notepad.exe.exe, if notepad.exe was copied/renamed to notepad.exe.exe, then it is not executable anymore?

Found errors in Test_Executable():
function RunTheTest[35]..Test_Executable line 5: Expected 0 but got 1
function RunTheTest[35]..Test_Executable line 6: Expected 0 but got 1

Copy link
Contributor Author

@janlazo janlazo Oct 7, 2018

Choose a reason for hiding this comment

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

Forgot that executable checks files in PATH. shell32.dll is in PATH but dll is not in PATHEXT by default so it is not executable. win.ini is in PATH (C:\Windows\win.ini on Windows 8.1) and opens notepad so it is executable. notepad.exe.exe is not in PATH (unless it was created elsewhere) so it is not executable here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

win.ini is loaded to notepad because of the default file assocation between inifile and notepad on Windows.
In cmd.exe, user can associate file extensions with a filetype and a default command via assoc and ftype commands.

@justinmk
Copy link
Member

justinmk commented Oct 8, 2018

Do you want to merge this, or are you planning to check/fix the PATHEXT logic (if needed)?

@janlazo
Copy link
Contributor Author

janlazo commented Oct 8, 2018

Not sure what to fix. If there's a fix, then it's a file permission issue like in Unix. Using File Explorer to check file properties dialog, there is Security tab that shows the file permissions. One of which is Read & execute permission, separate from Read permission. Fix is to check that "Read & execute" permission (is that handled by libuv?)

PATHEXT allows the user to "execute" files while omitting the file extensions found in assoc (or the equivalent registry check). assoc associates file extension with a filetype which ftype uses to run commands based on the filetype. assoc and ftype are internal cmd.exe commands.
What's strange is that I can "execute" unassociated file extensions because it opens notepad and dll files are not "executable" because ftype does not handle dll files.
User can fix this by running dll files with run32dll (as I do in my vimrc)
or by appending ;.dll to PATHEXT to open dll files with notepad.
As long as the user can "read and execute" the file, then the file is "executable".
Perhaps PATHEXT is for the shell only and powershell supports it for backward compatibility with cmd.exe. .ps1 is not in PATHEXT by default but it is executable in powershell.

@justinmk
Copy link
Member

justinmk commented Oct 8, 2018

We deal with PATHEXT in os_can_exe.

Perhaps PATHEXT is for the shell only and powershell supports it for backward compatibility with cmd.exe. .ps1 is not in PATHEXT by default but it is executable in powershell

Ah, good point.

Anyways, it looks like call assert_equal(0, executable('win.ini')) is failing in the AppVeyor log. Shall we just change it to 1 for now?

executable() on Windows has been useless for decades, and I wouldn't be surprised if 8.1.0454 gets reverted. It seems like it was rushed.

@janlazo
Copy link
Contributor Author

janlazo commented Oct 8, 2018

Anyways, it looks like call assert_equal(0, executable('win.ini')) is failing in the AppVeyor log. Shall we just change it to 1 for now?

Sure.

Windows has "Read and execute" permission via ACL
but nvim and libuv do not support ACL.
Windows does not support the executable bit in chmod-style permissions
but it is safe to assume that if the file exists and is readable,
then it is most likely executable.
This means that win.ini and shell32.dll are "executable"
because they exist, are readable, and are in PATH.

PATHEXT does not affect the executable permission of a file;
it exists to run files on the shell while omitting the file extension.
Assume that PATHEXT is intended for cmd.exe only
because powershell can execute powershell files (ie. *.ps1)
without changing PATHEXT or related cmd.exe environment variable.

In the future, nvim should check the outputs of 'assoc' and 'ftype',
cmd.exe internal commands, or check the registry.
Powershell can be used for ACL if C++/C# API is too difficult to use.
@justinmk justinmk merged commit 05cbe0d into neovim:master Oct 8, 2018
@justinmk justinmk removed the RFC label Oct 8, 2018
@janlazo janlazo deleted the vim-8.0.1807 branch October 8, 2018 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform:windows vim-patch See https://neovim.io/doc/user/dev_vimpatch.html
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Scanning:" Ins-Completion Messages
3 participants