Charles Campbell wrote:
>> I think it would be best to NOT test when under Windows
>> because there is no reasonable way to do so. If there were a
>> reasonable way for a script to store persistent data, you
>> could consider displaying a message the first time one of the
>> commands is invoked, letting the user know that netrw will
>> use 'move', 'mkdir', 'rmdir' as a default (lot of hassle and
>> potentially fragile code!).
>
> I suppose that I could test for executable("cmd"), and assume
> that move/rmdir/mkdir will work if cmd is on the path. Is
> that right?
It is correct that if Vim uses cmd (which would run cmd.exe) to
execute a command, then cmd would perform the following commands
itself: start move copy md mkdir rd rmdir (on a standard Windows
after Win9x, there is no executable with these names).
Win9x used command.com and not cmd.exe as the shell, while I
believe all Windows systems in the NT family (to present day)
provide cmd.exe. I do not know if the newer shells in recent
Windows replace or extend cmd.exe.
The problem is that (I think) Vim uses the 'shell' option to
determine what shell to use to run :! commands, and some users
would change that to some quirky shell like 4NT or a host of
others. If netrw checks for 'cmd', it could conceivably fail the
check but 'move' and 'copy' and so on _would_ actually work
because the user's shell does support those commands.
I think the best thing would be to just run the command (like
'move') and on the first error display a comprehensive error
indicating that the move failed and things the user might do.
All you can do is hope that v:shell_error will be nonzero when
an error occurs.
I wrote the following to check executable():
function! CheckExec()
for c in split('cmd start move copy md mkdir rd rmdir')
echo c . ' : ' . executable(c)
endfor
endfunction
call CheckExec()
The results on Windows XP are:
cmd : 1
start : 0
move : 0
copy : 0
md : 0
mkdir : 0
rd : 0
rmdir : 0
Each of the above is a valid command executed by cmd.exe.
However, when Vim sees ":!start xxx", Vim executes xxx
asynchronously (Vim does not run 'start').
Re your other message: I noticed the extra 'endif' in netrw.vim
when using the 'gx' command (it failed with a syntax error).
Warning to anyone who tries that: save your buffers first
because the resulting error messages are REALLY confusing.
John
--
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