最佳答案
输入 exit
就可以退出 PowerShell。到目前为止还不错。但是这到底是什么呢?
PS Home:\> gcm exit
Get-Command : The term 'exit' is not recognized as the name of a cmdlet, function, script file, or operable program. Ch
eck the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:4
+ gcm <<<< exit
+ CategoryInfo : ObjectNotFound: (exit:String) [Get-Command], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.GetCommandCommand
所以它既不是 cmdlet,也不是函数、脚本或程序。
不幸的是,这也意味着不能为 exit
创建别名:
PS Home:\> New-Alias ^D exit
PS Home:\> ^D
Cannot resolve alias '♦' because it refers to term 'exit', which is not recognized as a cmdlet, function, operable prog
ram, or script file. Verify the term and try again.
At line:1 char:2
+ ♦ <<<<
+ CategoryInfo : ObjectNotFound: (♦:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : AliasNotResolvedException
还有没有其他没有命令的命令?
仅供参考: 我知道我可以简单地把它包装成一个函数,我的配置文件有这些线
# exit with Ctrl+D
iex "function $([char]4) { exit }"
我的问题只是想知道这个命令到底是什么。