When did ^ become special on the command line?

G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.customize (More info?)

In versions of the command prompt like Win98, the ^ (caret or
circumflex, ASCII 94) is just an ordinary character. In the XP
command prompt it's the escape that causes the following character
to be ordinary. Example:

echo P(A^|B) is the conditional probability of A given B

My question is, with which version of Windows did ^ become special?
And is there some environment variable I can test that was created
or changed at the same time?

I need to do something like this, in other words:

set CARET=^^
if "%...%" = "..." set CARET=^

but I don't know how to test reliably for which versions of Windows
do (or don't) make the caret special.

 

Jerry

Distinguished
Dec 31, 2007
1,812
0
19,780
Archived from groups: microsoft.public.windowsxp.customize (More info?)

See the book "Microsoft Windows Command-Line" ISBN 0-7356-2038-5 for
answers.

> In versions of the command prompt like Win98, the ^ (caret or
> circumflex, ASCII 94) is just an ordinary character. In the XP
> command prompt it's the escape that causes the following character
> to be ordinary. Example:
>
> echo P(A^|B) is the conditional probability of A given B
>
> My question is, with which version of Windows did ^ become special?
> And is there some environment variable I can test that was created
> or changed at the same time?
>
> I need to do something like this, in other words:
>
> set CARET=^^
> if "%...%" = "..." set CARET=^
>
> but I don't know how to test reliably for which versions of Windows
> do (or don't) make the caret special.
>
> --
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.customize (More info?)

Windows NT4.x . Maybe earlier.

The caret ^ Treats the next symbol as a character.

[[To display a pipe (|) or redirection character (< or >) when you are using
echo, use a caret character immediately before the pipe or redirection
character (for example, ^>, ^<, or ^| ). If you need to use the caret
character (^), type two (^^). ]]
Echo
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/echo.mspx

[[Fourth, all reserved shell characters not in double quotes must be
escaped. These characters have special meaning to the Windows NT command
shell. The reserved shell characters are:

& | ( ) < > ^

To pass reserved shell characters as part of an argument for a command,
either the entire argument must be enclosed in double quotes, or the
reserved character must be escaped. Prefix a reserved character with a carat
(^) character to escape it. For example, the following command example will
not work as expected, because < and > are reserved shell characters:

1. C:\>echo <dir>
2. The syntax of the command is incorrect.

Instead, escape the two reserved characters, as follows:

1. C:\>echo ^<dir^>
2. <dir>

Typically, the reserved shell characters are not used in commands, so
collisions that require the use of escapes are rare. They do occur, however.
For example, the popular PKZIP program supports a -& switch to enable disk
spanning. To use this switch correctly under Windows NT, -^& must be typed.

Tip The carat character is itself a reserved shell character. Thus, to type
a carat character as part of a command argument, type two carats instead.
Escaping is necessary only when the normal shell interpretation of reserved
characters must be bypassed.]]
The Windows NT Command Shell
http://www.microsoft.com/technet/prodtechnol/winntas/deploy/shellscr.mspx

See also... Windows NT Batch File and Special Characters: & ( ) ^ ; | , and
<space>
Here...
MS-DOS: Windows Command Environment
http://www.dx21.com/HOME/ARTICLES/P2P/ARTICLE.ASP?CID=11

--
Hope this helps. Let us know.

Wes
MS-MVP Windows Shell/User


> In versions of the command prompt like Win98, the ^ (caret or
> circumflex, ASCII 94) is just an ordinary character. In the XP
> command prompt it's the escape that causes the following character
> to be ordinary. Example:
>
> echo P(A^|B) is the conditional probability of A given B
>
> My question is, with which version of Windows did ^ become special?
> And is there some environment variable I can test that was created
> or changed at the same time?
>
> I need to do something like this, in other words:
>
> set CARET=^^
> if "%...%" = "..." set CARET=^
>
> but I don't know how to test reliably for which versions of Windows
> do (or don't) make the caret special.
>
> --
>
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.customize (More info?)

"Wesley Vogel" wrote in microsoft.public.windowsxp.customize:
>Windows NT4.x . Maybe earlier.

Thanks...

--

 

Latest posts