As TCC parses the command line, it looks for the command separator, conditional commands (|| and &&), white space (spaces, tabs, and commas), percent signs % which indicate variables or batch file parameters to be expanded, and redirection and piping characters >, <, and |.

 

Normally, these special characters cannot be passed to a command as part of a parameter. However, you can include any of the special characters in a parameter by enclosing the entire parameter in single back quotes [`] or double quotes ["]. Although both back quotes and double quotes will let you build parameters that include special characters, they do not work the same way.

 

No alias or variable expansion is performed on a parameter enclosed in back quotes. Redirection symbols inside the back quotes are ignored. The back quotes are removed from the command line before the command is executed.

 

No alias expansion is performed when an expression is enclosed in double quotes. Redirection symbols inside double quotes are ignored. However, variable expansion is performed in expressions inside double quotes. The double quotes themselves will be passed to the command as part of the parameter.

 

For example, suppose you have a batch file CHKNAME.BTM which expects a name as its first parameter (%1). Normally the name is a single word. If you need to pass a two-word name with a space in it to this batch file you could use the command:

 

chkname `MY NAME`

 

Inside the batch file, %1 will have the value MY NAME, including the space. The back quotes caused TCC to pass the string to the batch file as a single parameter. The quotes keep characters together and reduce the number of parameters in the line.

 

For a more complex example, suppose the batch file QUOTES.BAT contains the following commands:

 

@echo off

echo Arg1 = %1

echo Arg2 = %2

echo Arg3 = %3

 

and that the environment variable FORVAR has been defined with this command:

 

set FORVAR=for

 

Now, if you enter the command

 

quotes `Now is the time %forvar` all good

 

The output from QUOTES.BAT will look like this:

 

Arg1 = Now is the time %forvar

Arg2 = all

Arg3 = good

 

But if you enter the command:

 

quotes "Now is the time %forvar" all good

 

The output from QUOTES.BAT will look like this:

 

Arg1 = "Now is the time for"

Arg2 = all

Arg3 = good

 

Notice that in both cases, the quotes keep characters together and reduce the number of parameters in the line.

 

The following example has 7 command line parameters, while the examples above only have 3:

 

quotes Now is the time %%forvar all good

 

(The double percent signs are needed in each case because the parameter is parsed twice, once when passed to the batch file and again in the ECHO command.)

 

When an alias is defined in a batch file or from the command line, its parameter can be enclosed in back quotes to prevent the expansion of replaceable parameters, variables, and multiple commands until the alias is invoked. See ALIAS for details.

 

You can disable and reenable back quotes and double quotes with the SETDOS /X command.