简体   繁体   English

Windows上的gvim:tempname()指向的文件不存在

[英]gvim on windows: file pointed to by tempname() does not exist

I'm trying to use a vim script that issues commands to sas, When i try to run the script i receive an error 我正在尝试使用向sas发出命令的vim脚本,当我尝试运行脚本时,我收到错误

"Can't open file ..path.. /AppData/Local/Temp/ .. temp file .. " “无法打开文件..路径.. / AppData / Local / Temp / ..临时文件..”

this is the path and file name returned by :tempname() 这是返回的路径和文件名:tempname()

After navigating to the appdata temp files directory, the temp file does not exist. 导航到appdata临时文件目录后,临时文件不存在。

I've tried manually changing the backup directory with set backupdir=~\\tmp (a directory I created) but that doesn't change the return value of :tempname() nor does the tempfile actually exist. 我尝试使用set backupdir =〜\\ tmp(我创建的目录)手动更改备份目录,但这不会更改:tempname()的返回值,也不会真正存在tempfile。

Two questions, 1. Is there a way to ensure vim is writing the file the script seems to need 2. can i rewrite the script to avoid needing a temp file? 两个问题,1。有没有办法确保vim正在编写脚本似乎需要的文件2.我可以重写脚本以避免需要临时文件吗? (just pass the path to the actual file to sas?) (只是将实际文件的路径传递给sas?)

the relevant part of the script is 脚本的相关部分是

    let returntxt = system("\"" .
    \ shellescape("C:\\Program\ Files\\SAS\\SASFoundation\\9.2\\sas.exe") .
    \ "\ -nosplash" . "\ -sysin" . "\ " .
    \ shellescape(expand("%:p")) .  "\"") 

" Shows the return messages from the SAS commandline (may be useful
" if no log produced)
:echo "*** SAS commandline: " . returntxt

Option 'backupdir' contains a list of directories where backup files are generated, it has nothing to do with temporary directory (except that it depends on where it is located, opposite is not true). 选项'backupdir'包含生成备份文件的目录列表,它与临时目录无关(除了它取决于它所在的位置,相反的情况不是这样)。 You should try using %TMP% or %TEMP% environment variable, either from vim using 您应该尝试使用%TMP%%TEMP%环境变量,来自vim using

let $TMP=expand('~/tmp')

or before vim is launched (don't know how to do this on windows). 或者在vim启动之前(不知道如何在Windows上执行此操作)。 Using let $TMP does work for me under wine, but only for existing temporary directories. 使用let $TMP确实可以在wine下使用,但仅适用于现有的临时目录。

Note that your system() call is rather strange: shellescape() should already add all needed quotes so that surrounding "\\"" are not required (if it does not you should properly configure 'shell*' options). You also don't need to escape spaces: "\\ " and " " are exactly the same strings. 请注意,你的system()调用很奇怪: shellescape()应该已经添加了所有需要的引号,因此不需要周围的"\\"" (如果不是你应该正确配置'shell *'选项)。你也不要需要转义空格: "\\ "" "是完全相同的字符串。

About second question: you can try passing file contents as a second argument to system() , but if file may contain NULLs it is not going to work. 关于第二个问题:您可以尝试将文件内容作为第二个参数传递给system() ,但是如果文件可能包含NULL,则它不会起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM