`Back quotes` - command line vs. batch file

May 20, 2008
11,285
95
Syracuse, NY, USA
I've been having a lot of trouble with back quotes on the command line not doing what I expect and I keep getting the feeling that they don't work like they have for many years. Maybe I shouldn't have to ask this but ...

The help says

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.

I use this line in several BTMs and it works.

Code:
function tformat `%@instr[0,4,%1]-%@instr[4,2,%1]-%@instr[6,2,%1] %@instr[8,2,%1]:%@instr[10,2,%1]:%@instr[12,2,%1].%@instr[15,3,%1]`

If I use it at a command line, it doesn't work.

Code:
v:\> function tformat `%@instr[0,4,%1]-%@instr[4,2,%1]-%@instr[6,2,%1] %@instr[8,2,%1]:%@instr[10,2,%1]:%@instr[12,2,%1].%@instr[15,3,%1
]`

v:\> function tf*
tformat=-- ::.

And the example from the "Quoting" page in the help doesn't work as that page says.

Code:
v:\> type quotes.bat
@echo off
echo Arg1 = %1
echo Arg2 = %2
echo Arg3 = %3

v:\> set forvar=for

v:\> quotes `Now is the time %forvar` all good
Arg1 = Now
Arg2 = is
Arg3 = the

The help says I should see (and I kinda expect to see)

Code:
Arg1 = Now is the time %forvar
Arg2 = all
Arg3 = good

What's going on?
 
Last edited:

samintz

Scott Mintz
May 20, 2008
1,488
15
Solon, OH, USA
I cannot replicate your issue. It is working correctly for me. Although, when I run your Quotes example, I see:
Code:
$ set forvar=for
$ quotes `Now is the time %forvar` all good
Arg1 = Now is the time for
Arg2 = all
Arg3 = good

So the backquotes got removed and %forvar gets expanded for the echo.
 
May 20, 2008
11,285
95
Syracuse, NY, USA
I cannot replicate your issue. It is working correctly for me. Although, when I run your Quotes example, I see:
Code:
$ set forvar=for
$ quotes `Now is the time %forvar` all good
Arg1 = Now is the time for
Arg2 = all
Arg3 = good

So the backquotes got removed and %forvar gets expanded for the echo.
That's different from mine but still contrary to what the help says and shows.
 
May 20, 2008
11,285
95
Syracuse, NY, USA
If I start TCC with /IIPS, I get the likes of these, which still don't look right.

Code:
v:\> quotes.bat `%o` bar
Arg1 =
Arg2 = bar
Arg3 =

v:\> quotes.bat `oo` bar
Arg1 = oo
Arg2 = bar
Arg3 =

v:\> quotes `Now is the time %forvar` all good

v:\>

And started like that, the back quotes appear in a history recalled command. That's not the case without /IIPS (which also seems wrong).
 
May 20, 2008
11,285
95
Syracuse, NY, USA
I see this difference.

Code:
d:\tc27> which _npids
_npids is a plugin variable (SYSUTILS)

d:\tc27> echo `%_npids`
104

d:\tc27> plugin /u 4utils

d:\tc27> echo `%_npids`
%_npids

d:\tc27>

Scott, do you use 4UTILS?

Also, when it's working right (4UTILS unloaded) back quotes show up in history-recalled commands; not so when 4UTILS is loaded.

I'll look at it but I haven't a clue where to start.
 
May 20, 2008
11,285
95
Syracuse, NY, USA
Hmmm! I had these (far below) in 4UTILS (a recent addition) along with the declarations and DEF-file/PLUGININFO entries to make them work. When I removed them, back quoting on the command line started working correctly. Rex ... any ideas why they'd make a difference?

And the QUOTES.BAT example in the help is in error. When you quotes `Now is the time %forvar`, the variable isn't expanded when the BAT is called, but it is expanded when it's ECHO'd. So Scott's observations are correct.

Code:
INT WINAPI UNKNOWN_CMD (LPWSTR psz)
{
    return 0xFEDCBA98;
}

INT WINAPI PRE_INPUT( LPWSTR psz )
{
    return 0xFEDCBA98;
}

INT WINAPI PRE_EXEC( LPWSTR psz )
{
    return 0xFEDCBA98;
}

INT WINAPI POST_EXEC( LPWSTR psz )
{
    return 0xFEDCBA98;
}
 
Similar threads
Thread starter Title Forum Replies Date
rconn News Take Command / TCC / CMDebug / TCC-RT v28 Released Support 0
T Take Command 28: Lua reports version 5.4.0 (5.4.3 expected) Support 0
Jay Sage WAD Possible Bug With OPTION Command With @FILE Support 5
rconn News Take Command / TCC / CMDebug / TCC-RT 27.01.24 uploaded Support 0
J Take command does not start on Windows 10 Support 3
Jay Sage WAD Failure of Alias Command with /Z Option Support 14
Phileosophos Is there any way to open the Take Command options dialog from the command line? Support 7
Phileosophos Command-line Editing Shortkeys That Fail Support 6
fpefpe How to? free (internal) command Support 0
rconn News Take Command / TCC / CMDebug / TCC-RT 27.01.23 uploaded Support 0
T How to? retain command history across reboot? Support 6
rconn News Take Command / TCC / CMDebug / TCC-RT v27.01 Build 22 Uploaded Support 0
Jay Sage Bug With Flow Control and/or Command Grouping Support 2
GermanDirk How to? EVENTLOG Command with simple User Rights not functional Support 4
Jay Sage Take Command Is Too Fast! Support 4
Jay Sage Comparison of IF with Command Group and IFF Support 6
D Open Windows 10 Photos app from command line Support 11
rconn News Take Command / TCC / CMDebug / TCC-RT 27.0.21 uploaded Support 0
rconn News Take Command / TCC / CMDebug / TCC-RT 27.0.20 uploaded Support 0
U Can not get/start Take Command gui Support 1
rconn News Take Command / TCC / CMDebug / TCC-RT 27.0.19 Support 0
S Increasing Font Point Size in Command Tabs Support 2
mfarah Fixed The DATE command produces the wrong error message. Support 1
vefatica Command name mix-up Support 3
FreezerBurnt "Missing SETLOCAL" when initializing Visual Studio Command Prompt. Support 9
E How to? Closing desktop created by DESKTOP command Support 10
rconn News Take Command / TCC / CMDebug / TCC-RT v27.0.18 Support 0
K Take Command fox XP? Support 7
Joe Caverly Documentation Replace internal command with LIBRARY command Support 0
fpefpe How to? command echo in title line/bar Support 2
U Command help on file names Support 5
vefatica Command line DO with no closing parenthesis? Support 9
vefatica Command history search is off Support 7
H How to? How can I say "if the command separator is not ~ then setdos /C~" Support 8
N Command execution slows down in TCC Prompt after a while Support 6
R Long commands retrieved from command history have blank line when wrapped Support 20
jpeni Take Command Language Examples Support 1
rconn News Take Command / TCC / CMDebug / TCC-RT 26.02.41 Uploaded Support 0
fpefpe winfr command Support 4
Dmitry L. Kobyakov Fixed The SETARRAY /R command works incorrectly with cyrillic files Support 2
M Selecting test "off by one" problem in Take command Support 4
Dmitry L. Kobyakov Documentation Error in the Help: the WINDOW command Support 0
R How to? Open Take Command at current folder Support 7
rconn News Take Command / TCC / CMDebug / TCC-RT 26.01.40 uploaded Support 0
C TEE command appending null characters to output Support 6
vefatica IDE external command syntax color? Support 1
rconn News Take Command / TCC / CMDebug / TCC-RT 26.0.37 Uploaded Support 0
Alpengreis List command: text truncated in find box (german) Support 9
C How to? Mouse support in WSL when in Take Command Tab Support 2
rconn News Take Command / TCC / CMDebug / TCC-RT 26.0.28 Support 0

Similar threads