如何使用 "a=1" 形式的字符串参数 运行 来自 Cygwin bash 的 windows 批处理脚本?

How to run a windows batch script from Cygwin bash with a string parameter of the form "a=1"?

我有以下简单的 Windows 批处理脚本:

@echo off

echo Parameter 1: "%~1"
echo Parameter 2: "%~2"

当我从 Windows 命令行 (cmd) 执行它时,我得到以下所需的输出:

C:\windows-script.bat "a=1" b
Parameter 1: "a=1"
Parameter 2: "b"

我现在想从 Cygwin bash 命令行执行相同的脚本并获得相同的输出。不幸的是,我无法实现我想要的。以下是三个不成功的试验:

$ /cygdrive/c/windows-script.bat "a=1" b
Parameter 1: "a"
Parameter 2: "1"
$ /cygdrive/c/windows-script.bat 'a=1' b
Parameter 1: "a"
Parameter 2: "1"
$ /cygdrive/c/windows-script.bat '"a=1"' b
Parameter 1: "\"a"
Parameter 2: "1\"""

知道如何以所需方式从 Cygwin bash 执行批处理脚本吗?

这是运行的一种方式:

$ cmd <<< 'C:\windows-script.bat "a=1" b'

<<< 的语法相当于键入:

cmd

然后输入:

C:\windows-script.bat "a=1" b

有关 <<< 的更多详细信息,请参阅 man bash