On Monday, April 9, 2012 8:59:48 AM UTC-5, Charles Campbell wrote:
> Hello,
>
> I have a request of a windows person out there (I currently don't have
> access to a windows box).
>
> The latest netrw asks users to consider setting up local commands for
> copy/mkdir/rmdir, but I've been told that there really aren't any such
> commands available under Windows; instead, they're available only under
> a shell such as cmd.exe.
>
I'm confused by this statement. For most users, to run external commands, Vim
automatically invokes cmd.exe to run anything.
> So, how best to make this work? I was thinking
>
> if has("win32") || has("win95") || has("win64") || has("win16")
> if executable("cmd")
> let g:netrw_localmovecmd= "cmd move"
> endif
> endif
>
What would the fallback be, if somehow (I can't imagine why) cmd.exe is not
found? What is the point of testing first?
As I mentioned, by default, Vim already invokes cmd.exe to run its external
commands, so prefixing cmd should not be necessary. If you decide you need to
do so anyway, you probably need to use the /c flag, e.g. "cmd /c move", to run
the command given and exit the shell. There's also /k, which will run the
command but remain in the shell (probably you don't want this, but it can be
useful for debugging).
> but I'd like someone to let me know if this works first.
>
> The g:netrw_localmovecmd is used in a line such as
>
> let ret= system(g:netrw_localmovecmd." ".shellescape(fname)."
> ".shellescape(s:netrwmftgt))
>
> I'd try this out on my home computer (which has Windows Vista) but I
> haven't had any luck compiling a windows-style vim there lately (so its
> a cygwin-based version).
>
> Regards,
> Chip Campbell
A small note, if you're messing with this sort of thing, "xcopy" is a more
powerful command than a regular "copy" if it is available.
Also see the discussion on the following patches:
7.3.443 MS-Windows: 'shcf' and 'sxq' defaults are not very good
7.3.445 (after 7.3.443) can't properly escape commands for cmd.exe
7.3.446 (after 7.3.445) external command with special char doesnt work
7.3.447 (after 7.3.446) External commands with "start" do not work
7.3.448 (after 7.3.447) Win32: Still a problem with "!start /b"
7.3.450 (after 7.3.448) Win32: Still a problem with "!start /b"
With all of these patches, Vim should "do the right thing" by default. With
none or only some of them, there may be problems using external commands in
some situations. It probably shouldn't matter with the built-ins, though.
Also note that "shellslash" affects the behavior of "shellescape()" in a way
that breaks external commands on Windows if the user is using the default shell
of cmd.exe.
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php