【问题标题】:Launch C program in Cygwin Environment through command line通过命令行在 Cygwin 环境中启动 C 程序
【发布时间】:2015-09-11 04:14:37
【问题描述】:

我安装了 Cygwin 来编译和运行 C 程序。我正在尝试使用 Notepad++ 作为我的编辑器来编写我自己的 shell 程序。当我从命令行(使用 nppexec)执行编译的 .exe 文件时,它在 Cygwin 环境之外运行。
以下重定向命令将无法使用 Window 的 cmd 运行:

$ sort -r < test3.txt
-rThe system cannot find the file specified.

但是当程序通过 Cygwin 的 Mintty 执行时可以工作:

$ sort -r < test3.txt
test3.txt
test.txt
sh.exe
sh.c
1.txt

我正在使用以下代码运行 nppexec 来启动程序:

cd $(CURRENT_DIRECTORY)

gcc "$(FILE_NAME)" -o $(NAME_PART).exe

cmd.exe /c start cmd /k $(NAME_PART).exe

如何编辑以上内容以在 Cygwin 环境中启动?
我试过没有运气:

cmd /c start mintty ./$(NAME_PART).exe

【问题讨论】:

    标签: c cygwin notepad++ mintty


    【解决方案1】:

    Windows 命令行有它自己的sort 命令,其行为与通过 Cygwin 命令行可用的变体不同。

    【讨论】:

    • @George 我不记得sort 是内置命令还是外部程序。如果它是一个外部程序,您可以更改您的系统 PATH 设置,将 Cygwins bin 路径放在 Windows 系统目录之前。但是,当 Windows 世界的其他地方需要标准的 Windows 命令时,这可能会导致其他问题。
    • @George 您可以创建 cygwin 排序命令的副本,例如调用它gsort(用于 gnu 排序)然后在您的脚本中使用 gsort。这样它就不会干扰 Windows 世界的其他部分。
    猜你喜欢
    • 2013-06-18
    • 2015-09-14
    • 1970-01-01
    • 2018-05-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-28
    • 1970-01-01
    相关资源
    最近更新 更多