So I was messing around with variables, and found out the if i run the following command
所以我搞乱变量,发现如果我运行以下命令
set var1=|
It gives me this error
它给了我这个错误
The syntax of this command is incorrect
Why does it say that?
为什么这么说?
2 个解决方案
#1
0
Some symbols may do this. To fix this error you have to use an escape character. So try
有些符号可能会这样做。要修复此错误,您必须使用转义字符。所以试试吧
set var=^|
^ is the escape character you use.
^是您使用的转义字符。
#2
1
pipe (|
) is a redirector which takes the output of one command and feeds it into the next. You've not provided a next command.
pipe(|)是一个重定向器,它接受一个命令的输出并将其输入到下一个命令。你没有提供下一个命令。
With all redirectors, if you wannt to use them literally, then you need either
对于所有重定向器,如果你想在字面上使用它们,那么你需要
set var1=^|
where the caret tells cmd
that the following character is a literal, not part of a command
插入符告诉cmd以下字符是文字,而不是命令的一部分
or
set "var1=|"
where "quoting the arguments" acts similarly, with the added benefit that any invisible trailing spaces on the line are not included in the valus assigned.
其中“引用参数”的行为类似,附加的好处是线上的任何不可见的尾随空格都不包含在分配的值中。
#1
0
Some symbols may do this. To fix this error you have to use an escape character. So try
有些符号可能会这样做。要修复此错误,您必须使用转义字符。所以试试吧
set var=^|
^ is the escape character you use.
^是您使用的转义字符。
#2
1
pipe (|
) is a redirector which takes the output of one command and feeds it into the next. You've not provided a next command.
pipe(|)是一个重定向器,它接受一个命令的输出并将其输入到下一个命令。你没有提供下一个命令。
With all redirectors, if you wannt to use them literally, then you need either
对于所有重定向器,如果你想在字面上使用它们,那么你需要
set var1=^|
where the caret tells cmd
that the following character is a literal, not part of a command
插入符告诉cmd以下字符是文字,而不是命令的一部分
or
set "var1=|"
where "quoting the arguments" acts similarly, with the added benefit that any invisible trailing spaces on the line are not included in the valus assigned.
其中“引用参数”的行为类似,附加的好处是线上的任何不可见的尾随空格都不包含在分配的值中。