如何处理powershell命令中的点? [英] How to handle dots in powershell commands?
问题描述
下面的命令在命令行中有效
The command below works in command line
mvn clean install -Denunciate.skip
但在 powershell 中出现错误
But breaks in powershell with the error
[错误] 未知生命周期阶段.skip".您必须以以下格式指定有效的生命周期阶段或目标
[ERROR] Unknown lifecycle phase ".skip". You must specify a valid lifecycle phase or a goal in the format
推荐答案
使用引号会有所帮助,尤其是对于实际的 PowerShell 代码.但是,您只是尝试使用常规命令.您可以使用 停止解析参数一个>
Using quotes can help, especially with actual PowerShell code. However you are just trying to use a regular command. You can keep the PowerShell parser from misinterpreting your code by using the stop-parsing parameter
Windows PowerShell 3.0 中引入的停止解析符号 (--%
),指示 Windows PowerShell 避免将输入解释为Windows PowerShell 命令或表达式.
The stop-parsing symbol (
--%
), introduced in Windows PowerShell 3.0, directs Windows PowerShell to refrain from interpreting input as Windows PowerShell commands or expressions.
在 Windows PowerShell 中调用可执行程序时,将程序参数前的停止解析符号.这种技术是比使用转义字符来防止误解要容易得多.
When calling an executable program in Windows PowerShell, place the stop-parsing symbol before the program arguments. This technique is much easier than using escape characters to prevent misinterpretation.
因此,对于您的命令,您也可以这样做.
So for your command you could have also done this.
mvn --% clean install -"Denunciate.skip"
如果您确实在其中混合了变量,则只需根据需要移动停止解析器.
If you did have variables mixed in there then just move the stop parser as needed.
这篇关于如何处理powershell命令中的点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!