【问题标题】:Windows command line %argument was unexpected at this time (with single percentage!) [closed]此时 Windows 命令行 %argument 出乎意料(只有一个百分比!)[关闭]
【发布时间】:2017-08-04 20:03:16
【问题描述】:

我正在尝试在 命令提示符 中运行以下命令,参数只有一个百分比,因为它应该用于命令提示符说明:

for /F %remote in ('git branch -a') do (git branch --track %remote) && git fetch --all && git pull --all

但我仍然收到以下错误:

%remote 此时出乎意料。

这种“此时的争论出乎意料”存在很多问题。我已经搜索过,但几乎所有解决方案都提到了使用 % 或 %% 之间的相同混淆。双倍百分比只能在批处理文件中使用。但我使用了正确的符号。为什么它不起作用?

可能是因为括号?我不知道this issue mentioned on Microsoft's website 是否相关。

【问题讨论】:

  • 帮助文件第三行:%variable Specifies a single letter replaceable parameter.

标签: batch-file windows-console


【解决方案1】:

阅读文档

C:\>for /?
Runs a specified command for each file in a set of files.

FOR %variable IN (set) DO command [command-parameters]

  %variable  Specifies a single letter replaceable parameter.

请注意文档的第 3 行如何表示“单字母”

(完整的帮助文本长达 153 行。我建议全部阅读)

【讨论】:

  • 您的头像可能在您输入时非常清楚地代表了您,嗯? :)。谢谢。
  • @Axonn,一个敏锐的观察!糟糕的是,翻白眼不是动画。哈哈。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-09-11
  • 1970-01-01
  • 2018-07-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多