windows 使用 vscode 的一些鬼畜问题
省流:都是 powershell 搞的。
1. &&
首先你在 cmd 中运行 A 命令 && B 命令 是完全合法的,到 vscode 中却报错:
所在位置 行:1 字符: 63
+ g++ -O2 -std=c++14 1.cpp -o 1 -DLOCAL "-Wl,--stack=512000000" & ./1
+ ~
不允许使用与号(&)。& 运算符是为将来使用而保留的;请用双引号将与号引起来("&"),以将其作为字符串的一部分传递。
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : AmpersandNotAllowed
这是因为 powershell 原生使用的是 ; 表示无条件按顺序执行。所以写成 A 命令; B 命令 就对了。
2. fc
想要在集成终端中比较文件,结果:
Format-Custom : 找不到接受实际参数“shi.out”的位置形式参数。
所在位置 行:1 字符: 1
+ fc my.out shi.out
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Format-Custom],ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.FormatCustomCommand
这是因为 powershell 把 fc 被绑到 Format-Custom 上了。解决方法是加上 .exe。
PS D:\work> fc.exe my.out shi.out
正在比较文件 my.out 和 SHI.OUT
不过 vscode 自带比较功能,直接右键选 Select for compare 和 Compare with selected 就可以直接比较了。
3. Once and for all
- 换用 Linux 系统,会少很多反人类的解析方法。对了,
-Wl,--stack=1145141919要用引号包含起来也是为了防止 powershell 把,瞎 * * 解析掉。 - 在 windows 中使用 Dev-c++,在文件夹中乖乖使用 cmd。
- 在 powershell 中强制用 cmd,命令是
cmd /c "[你想要执行的命令 + 参数]",或者直接输入 cmd,终端就会变成命令提示符。

浙公网安备 33010602011771号