批处理到 Bash/Shell 脚本转换器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26190258/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Batch to Bash/Shell Script Converter
提问by ShadowDust99
I have recently purchased a Mac and have found out that it does not have any support for Batch (.bat) files at all. All I want is a website that will convert a Batch file program, to a Bash file program so I don't have to learn a whole new programming language, since I am so used to the Batch programming. Is there an online converter or possibly an app/program that could be found on a website or on the Mac App Store. If so, could you please tell me the name of the program, where I can find it, and a link to it. Thanks!
我最近购买了一台 Mac,发现它根本不支持批处理 (.bat) 文件。我想要的只是一个将批处理文件程序转换为 Bash 文件程序的网站,这样我就不必学习全新的编程语言,因为我已经习惯了批处理编程。是否有可以在网站或 Mac App Store 上找到的在线转换器或可能的应用程序/程序。如果是这样,请告诉我该程序的名称,在哪里可以找到它,以及它的链接。谢谢!
回答by John Zwinck
There is no possible way to do this. Why? Because not only are both the source and destination languages Turing complete, both are hideous piles of accumulated hacks from decades upon decades of maintenance programmers. And not only that, let's say you map all the syntax from Windows Batch to Bash (careful: version 3.2 only, Mac doesn't have newer!). Then what will you do when the original script invokes an external program? Will you know to map Windows Movie Maker to iMovie? Microsoft Office to iWork? Internet Explorer to Safari?
没有办法做到这一点。为什么?因为不仅源语言和目标语言图灵都是完整的,而且两者都是几十年又几十年的维护程序员积累的骇人听闻的黑客。不仅如此,假设您将所有语法从 Windows Batch 映射到 Bash(注意:仅限 3.2 版,Mac 没有更新的!)。那么当原脚本调用外部程序时,你会怎么做呢?您知道将 Windows Movie Maker 映射到 iMovie 吗?Microsoft Office 到 iWork?Internet Explorer 到 Safari?
What about the fact that the two different systems have different rules about what constitutes a valid filename? If the source script mentions C:\Windows, what does that mean on a Mac?
两个不同的系统对构成有效文件名的内容有不同的规则,这又如何呢?如果源脚本提到 C:\Windows,这在 Mac 上意味着什么?
There is a never ending amount of work required to do what you're asking. Perhaps you can narrow the scope (a lot).
要完成您的要求,需要做的工作量永无止境。也许你可以缩小范围(很多)。