-
Notifications
You must be signed in to change notification settings - Fork 329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve windows shell handling #1309
Conversation
Thank you so much! I had a bit of experience with quoting on Windows with #1176, and it was maddening. cc #1276 and @kietfsek: perhaps you could help test this out? I haven't tried this out yet; I'd have to remember how to spin up a Windows VM to do it. Still, here are some thoughts from memory:
|
Sorry to intrude here. Does this fix a quoting issue that causes unexpected behavior on Windows? For example, if you run a following command:
It actually creates the new directory in root of the C drive and not the current working directory. Whereas without quotes it properly creates a directory in the current working directory:
This happens when I run lf with the default configuration in Powershell. If the problem still persists, I can create a new issue about it. |
@ilyagr: I am willing to help. However, although I am OK on technical stuff (figuring out how to download a branch and set up the build environment -- I can work them out on my own), I am not familiar with GitHub interface and I have very limited experience of contributing in any form to a project on GitHub. I am willing to learn in order to help the testing, but I will need guidance. |
@kietfsek Here's some guidance. Let me know if you still have questions; I'm not sure exactly what you need help with. Checking out the PRThere are a few different ways. A. You could use the Github Desktop tool, especially on Windows.I haven't used it for a long time, but I remember it to be pretty straightforward. B. You could clone Joe's repo from
|
I think that's good and enough information. Thanks. I will start working on it later when I have time. |
@veltza I have tested For PowerShell, I had to use single quotes (i.e. |
@ilyagr I got this to work by quoting the |
Accidental commit This reverts commit 5ff3265.
That's strange, I found |
So after a bit more testing with PowerShell, I do have some slight bad news. The quoting for EDIT: Fixed in 3e89fde |
Update: I realized what went wrong when testing the case that After I ruled this out, I did see So:
(tested on latest commit, 130c63c) |
Thank you very much @joelim-work for the patch and @ilyagr @veltza @kietfsek for the reviews and testings. This patch will certainly be much appreciated by our Windows users. |
Changes:
shellCommand
function inos_windows.go
to handle quoted arguments with spaces. I got the idea from os/exec: Cannot execute command with space in the name on Windows, when there are parameters golang/go#17149 to set the command line directly incmd.SysProcAttr
.quoteString
function which quotes strings depending if the OS is Windows or not. This now means that displaying the documentation via<f-1>
or:doc
now works even if thelf
path contains spaces (see Make the:doc
command work even iflf
is not in the PATH, addlf
environment variable #1176).exportFiles
function so that all the main logic is done insidenav.go
, and calls out to the abovequoteString
function to handle quoting.The following commands now work, at least on my machine:
Executables with spaces in their path now also work (from #1276):
mkdir
with a quoted string now properly creates the directory in the current location instead of atC:\
(from #1309 (comment)):I have also done some very brief testing with PowerShell, but I'm not so familiar with it so I would appreciate it if others helped to test it as well and make sure the changes are more stable. Hopefully we can avoid the situation where separate command-handling logic is required for CMD vs. PowerShell.