"Lucvdv" <firstname.lastname@example.org> wrote in message
> Just curious: are there any other built-in commands (in the old cmd
> terminology) left over besides "exit"?
Technically, it's not a command; it's an internal keyword used for control
flow, akin to break/continue/return/if and so on.
> Exit does what I expected it to do, quit didn't do anything, and after
> finding that out I just noticed this:
> PS C:\> set-alias quit exit
> PS C:\> quit
> Cannot resolve alias 'quit' because it refers to term 'exit', which is not
> recognized as a cmdlet, function, operable program, or script file. Verify
> the term and try again.
> At line:1 char:4
> + quit <<<<
You've stumbled across one of the important points about how PowerShell
interprets code. Here's another way to explain it.
PowerShell starts out in "expression" mode, attempting to match tokens to
things it understands internally: specific keywords, variables, or literal
values. If it doesn't find a match, it then goes to statement mode and tries
to treat the token as a command.
Since 'quit' is not recognized internally PS now tries to treat it as a
command, and sure enough, it's an alias for "exit". However, aliasing ONLY
works for commands! It looks for an alias,function,filter,cmdlet, or
external script or Windows native command named "exit" and doesn't find one.