批处理脚本不再起作用?
我正在使用 Ant、Java 和 CVSNT 在控制台窗口中的命令行上工作。 (Unix 极客被迫生活在 Windows 世界)
当我运行 cvsnt 命令时,批处理脚本不再起作用。这包括我使用的几个命令,包括 ant
和 vim
。
我可以打开一个新的控制台窗口,在该窗口中,一切都很好,所以它一定与该控制台窗口中的特定环境有关,每当我在 cvsnt 中执行某些操作时,就会发生这种情况。
有什么想法吗?有什么我应该寻找的吗?
I am working on the command line in the console window using Ant, Java, and CVSNT. (Unix geek forced to live in a Windows world)
When I run a cvsnt command, batch scripts no longer work. This includes several commands that I use including ant
and vim
.
I can open up a new console window, and in that window, everything is fine, so it must be something about that particular environment in that console window, and it happens whenever I do something in cvsnt.
Any ideas? Anything I should be looking for?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我今天遇到了完全相同的问题。问题在于 cvs.exe 对代码页执行了某些操作。我无法解释清楚是什么,但如果您重置代码页,bat 文件将再次开始工作。
一个例子可能会让这一点更清楚(在英国,我的默认代码页是 850,但是当我将 Windows 默认代码页设置为 437 时,也会发生同样的情况),
因此尽管代码页显然不受影响,但重置它会恢复 .bat 的功能文件。
为了解决这个问题,我使用了这样的脚本:
并通过它调用 cvs。如果有人可以评论为什么会发生这种代码页行为,我将最有兴趣知道。
I had the exact same problem today. The problem is that cvs.exe does something with the code page. I cannot explain quite what but if you reset the code page, bat files start working again.
An example may make this clearer (being in the UK, my default code page is 850, but the same thing happens when I have my Windows default as 437)
so although the code page is apparently unaffected, resetting it restores the functionality of .bat files.
To work around this problem, I am therefore using a script like this:
and invoking cvs through it. If anyone can comment on why this code-page behaviour is occurring I would be most interested to know.
CVSNT 2.5.05 将输出代码页设置为 65001 (UTF-8),并且不会将其设置回来。
不幸的是,Windows 对该代码页的处理被破坏,因此发生了糟糕的事情(包括无法运行批处理文件)。
一种解决方法是使用
CHCP
将代码页(输入和输出)重置为已知的工作代码页(437、850、1252 或其他),最好在同一行作为CVS
命令。例如:或者,如果您觉得更奇特,您实际上可以保存当前代码页并恢复它。
例如,下面是我用来更新工作目录中所有模块的批处理文件:
在同一行调用 CHCP 的重要性在于,如果代码页是 UTF,则不会处理批处理文件的下一行。
当然,修复bug将是更好的解决方案。
CVSNT 2.5.05 sets the output code page to 65001 (UTF-8) and does not set it back.
Unfortunately, Windows' handling of that code page is broken so bad things happen (including the inability to run batch files).
One workaround is to reset the code page (both input and output) to a known working one (437, 850, 1252 or others) using
CHCP
, preferably on the same line as theCVS
command. For example:Or, if you feel more fancy, you can actually save the current code page and restore it.
For example, here's a batch file that I use to update all the modules in my work directory:
The importance of invoking CHCP on the same line is that the next line of the batch file will not be processed if the code page is UTF.
Of course, fixing the bug will be a better solution.
一些版本控制客户端(我正在与您交谈 ClearCase)启动一个子 shell,该子 shell 可能会也可能不会带来以前的环境。我们放弃了在 Unix 上编写 ClearCase 脚本的尝试,因为我们无法使用 CC 命令编写脚本,因为它们打开了一个子 shell,而父脚本将继续自行进入 la-la-land。
Some version control clients (I'm talking to you ClearCase) start a sub-shell which may or may not bring the previous environment over with it. We gave up trying to script ClearCase on Unix because we couldn't write scripts with the CC commands in them because they opened a subshell and parent scripts would continue by themselves into la-la-land.