我试图在我的windows 10 PC上安装ArgoCD CLI,方法是按照网站上的命令替换版本,但收到以下错误。它似乎不喜欢+操作符?有人能帮忙吗?
PS C:\Users\dell.docker> $url = "https://github.com/argoproj/argo-cd/releases/download/“+ v2.2.3 + "/argocd-windows-amd64.exe"
At line:1 char:66
+ ... = "https://github.com/argoproj/argo-cd/releases/download/" + v2.2.3 ...
+ ~
You must provide a value expression following the '+' operator.
At line:1 char:67
+ ... ps://github.com/argoproj/argo-cd/releases/download/" + v2.2.3 + "/arg ...
+ ~~~~~~
Unexpected token 'v2.2.3' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : ExpectedValueExpression发布于 2022-01-23 14:39:15
您必须引用版本号:
$url = "https://github.com/argoproj/argo-cd/releases/download/" + 'v2.2.3' + "/argocd-windows-amd64.exe"当然,您也可以首先使用一个引号字符串,由于使用了),如果版本号是通过变量提供的,它甚至可以工作。
$version = 'v2.2.3' # Quoting is required here too - '...' is a verbatim string
$url = "https://github.com/argoproj/argo-cd/releases/download/$version/argocd-windows-amd64.exe"它似乎不喜欢+操作符
问题不在于+运算符,而是您打算使用的字符串文本-- v2.2.3 --没有引用。
运算符在PowerShell (表达式模式)中的表达式上下文中操作,在表达式中,所有字符串文字都需要引用。
相反,只有当您将参数传递给命令(参数模式)时,才可以传递字符串值(没有空格和其他元字符),而不引用:
Write-Output v2.2.3 # OK - quoting optional有关这两种基本解析模式的更多信息,请参见概念性解析帮助主题。
https://stackoverflow.com/questions/70822276
复制相似问题