bash - 使用 NppExec(和 Cygwin)在 Notepad++ 中的 Windows 上运行 bash shell 脚本

标签 bash shell cygwin notepad++ nppexec

我正在尝试重构如何使用 NPPExec 从 Notepad++ 中在我的 Windows 机器上执行 bash shell .sh 文件。 (我以前成功过,但是我的硬盘坏了,我不记得我以前是怎么做的。)

以前工作时,我会运行调用 .sh 文件的 NPPExec 脚本,它向我展示了 Notepad++ 中处理 .sh 文件的控制台输出,就好像它正在处理赛格温。

这是我尝试开始工作的示例 .sh 文件:

message="Testing"
echo $message

此文件位于 C: 的根目录中。

失败的尝试:

以下三种方法都不行:

  • 执行:C:\nppexec.sh

响应:

CreateProcess() failed with error code 193:
%1 is not a valid Win32 application.
  • 执行:npp_exec C:\nppexec.sh

响应:

message="Testing"
CreateProcess() failed with error code 2:
The system cannot find the file specified.    
$message
  • 添加#!/bin/bash 到 .sh 文件作为第一行只会在运行 npp_exec 时导致额外的错误:

    NPP_EXEC: C:\nppexec.sh
    #! /bin/bash
    CreateProcess() failed with error code 2:
    The system cannot find the file specified.
    

最佳答案

解决方案是直接调用 bash:

C:\cygwin\bin\bash --login -c "command.sh"

关于bash - 使用 NppExec(和 Cygwin)在 Notepad++ 中的 Windows 上运行 bash shell 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11234289/

相关文章:

bash - 终止终端后是否可以执行 bash 脚本?

Linux - 使用单个命令更新多个符号链接(symbolic link)

c - eclipse + CDT + Cygwin : How do you fix the "Multiple targets" bug?

c++ - 在 Cygwin 上执行的程序不报告抛出的异常

eclipse - Hadoop 0.20.2 Eclipse 插件未完全运行 - 不能 'Run on Hadoop'

linux - 使用 `date` 命令获取上个月、当前月和下个月

file - 根据名称在终端中移动内容

linux - 如何创建一个 bash 函数来创建多个命名目录,然后按扩展名组织它们包含的文件?

shell - 在 shell 脚本中执行 mailx 命令

shell - Neo4j - 通过 Neo4jShell 将密码查询文件结果导出到 .csv 或 .txt 文件