- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我有一个运行得很愉快的批处理文件,直到最后几次运行,但现在不是。违规代码如下:
set uncommittedchanges=1
for /f "tokens=* usebackq" %%a in (`"C:\Program Files\Git\cmd\git" -C "\my\git\repository" status`) do (
if "%%a" == "nothing to commit, working directory clean" (
set uncommittedchanges=0
)
)
我得到的错误是
'C:\Program' is not recognized as an internal or external command, operable program or batch file.
我确定自从上次运行以来我没有对这些行进行任何更改,并且我看不出代码有任何问题。
谁能发现问题所在,或者建议我可能无意中更改了影响 usebackq 的设置?
最佳答案
是调用子cmd.exe实例的bug。
您需要使用一种解决方法来避免第一个标记使用未转义的空格。
最简单的方法是使用 CALL
,因为它将您的程序 token 移动到第二个位置,并且它可以正常工作。
for /f "tokens=* usebackq" %%a in (`CALL "C:\Program Files\Git\cmd\git" -C "\my\git\repository" status`) do (
关于windows - "For"和 "usebackq"不使用反引号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37994355/
我有一个运行得很愉快的批处理文件,直到最后几次运行,但现在不是。违规代码如下: set uncommittedchanges=1 for /f "tokens=* usebackq" %%a in (
我有这个代码: setlocal enableextensions for "usebackq" %%i in (`dir /b`) do echo * %%i endlocal 我想做的很简单:打印
批处理脚本非常新。我需要将命令的输出分配给变量。我了解了 FOR/F 命令。我的命令有空格和双引号。所以我尝试使用 usebackq 选项。但它因空间错误而失败。 for /F "usebackq d
我想读取一个包含多个(未终止的)Kafka 主机的字符串,并使用 cmd for 将它们列出在单独的行中。 字符串如下: host1:9092,host2:9092,host3:9092,... 我所
我是一名优秀的程序员,十分优秀!