Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

Exit = last of the "built-in commands"?

Closed Thread
 
Thread Tools Display Modes
Old 11-09-2006   #1 (permalink)
Lucvdv
Guest


 

Exit = last of the "built-in commands"?

Just curious: are there any other built-in commands (in the old cmd
terminology) left over besides "exit"?

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 <<<<
Old 11-09-2006   #2 (permalink)
dreeschkind
Guest


 

RE: Exit = last of the "built-in commands"?

"Lucvdv" wrote:

> Just curious: are there any other built-in commands (in the old cmd
> terminology) left over besides "exit"?


Well, PowerShell has its own scripting language (IMHO cmd.exe does not have
anything that comes close to being a language) so you could just compare
"exit" with other common language keywords like "for" "while" "switch"
"break" etc.

> 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 <<<<


Thill will work:
PS> function exit {exit}
PS> set-alias quit exit
PS> quit

or even shorter:
function quit {exit}

Btw.:
I suggested that "exit" should be a customizable function like TabExpansion
or Prompt. This would enable for example saving or cleaning up various data
automatically (e.g. exporting history) when closing PowerShell without the
need to remember to call a special function or cmdlet with another name.
You can vote for this on the Connect site if you like this idea:

https://connect.microsoft.com/feedba...8962&SiteID=99

--
greetings
dreeschkind
Old 11-10-2006   #3 (permalink)
Alex K. Angelopoulos [MVP]
Guest


 

Re: Exit = last of the "built-in commands"?

"Lucvdv" <replace_name@null.net> wrote in message
news:n3k6l21p7sfs9bnk956rp2uqhkl4g8vrar@4ax.com...
> 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.


Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unwanted Multiple contacts in "To","CC","BCC" of email send catago xsailer Vista mail 1 4 Weeks Ago 08:34 AM
Vista not wotking with "My Computer" or "Control Panel", "Screen Saver" Platebanger Vista General 6 02-05-2008 08:54 AM
Cant turn off "built in protection"... esmnh Vista security 6 08-21-2007 07:00 PM
Acer Aspire 3023 Problem enabling "radio" for built in broadcom wi Chris Vista hardware & devices 3 06-21-2006 09:28 AM
Acer Aspire 3023 Problem enabling "radio" for built in broadcom wi Chris Vista hardware & devices 6 06-14-2006 08:13 PM








Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50