tcc /c "[...]" fails when run from third party terminal

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
Aug 16, 2008
124
0
#1
Hi,

I normally run TCC from ConEmu/FAR Manager[1]. FAR has a command prompt. FAR passes the commands to ComSpec via '%ComSpec% /c "command"'.

So when I execute "alias where" in FAR, FAR runs TCC and I see the result in FAR's terminal. This also works when I run FAR in conjunction with Console Emulator.

Console Emulator has a FAR plugin which enables tighter integration between FAR and Console Emulator[2]. When I load the plugin, commands like "alias where" start failing in FAR:

> alias where
TCC: Unknown command "alias where"

I reported this as a bug to the developer of Console Emulator. He replied that this is not a bug in the Console Emulator plugin ("Where is a bug?") but in TCC(!) because when I run ("from Windows")

[Win+R] tcc.exe /C "alias where" & cmd

it also fails with "TCC: Unknown command "alias where"".

I replied "Whatever the plugin does, it makes the commands fail that work without the plugin. This is obviously a bug."

Can anyone offer some insight into this issue?

Thorsten
[1] http://jpsoft.com/blogs/2012/04/windows-console-replacements-part-6-take-command-and-conemu/
[2] https://code.google.com/p/conemu-maximus5/wiki/ConEmuFarPlugin#ConEmu
 

samintz

Scott Mintz
May 20, 2008
1,204
11
Solon, OH, USA
#2
I'm running TCC v15.01.52 and I get expected behavior.
Code:
TCC: Not an alias "where"
Try running your command without the quotes:
Code:
tcc /c alias where
It's possible that the version of TCC you are running is trying to run "alias where" as opposed to ALIAS with an argument of "where".
-Scott
 
#3
Scott, I think you found the issue. TCC does not expect the whole command line to be quoted, which is the reason the failing command is shown as "alias where". The author of the FAR plugin did not test a valid invocation of TCC with Win+R:
tcc /c alias where
does not fail! FAR should give the user the option whether or not to quote the command line to be passed, so the TCC command it passes should look like:
%ComSpec% /c alias where

Of course, starting and stopping TCC (and all its DLLs) for each command you want to execute is not only very inefficient, but prevents you from using the start-up options you find in TCMD Help / TCC / Starting TCC / TCC Startup Options; some of them you can emulate in the default TCMD.INI, some others in TCSTART.BTM. Furthermore, since each invocation starts with the same bare environment passed by Windows or by ConEmu, results of a command are not available in subsequent commands.
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,385
39
Albuquerque, NM
prospero.unm.edu
#4
CMD.EXE has a fairly whimsical set of rules for deciding whether to strip or retain leading/trailing quote marks on its startup command line. Type CMD /?, hit Enter and then press the spacebar once to see the executive summary.

Should TCC.EXE emulate this Rube Goldberg behavior?
 
#5
CMD.EXE has a fairly whimsical set of rules for deciding whether to strip or retain leading/trailing quote marks on its startup command line. ... Should TCC.EXE emulate this Rube Goldberg behavior?
Absolutely NOT as default, though when Duplicate CMD bugs is selected, some may find it useful. While the CMD rules you referenced are not totally nonsensical (they seemed designed to retain quotation marks around one single LFN containing white space but without parentheses or other special characters in the filename, and no additional quoted strings in the command line), they are still incapable of passing many other potential strings to the TCC command specified. If in fact the OP wanted TCC to execute a batch file whose name contains white space, with a parameter string, the command format would be (e.g. to invoke TCC from a RUN box) %ComSpec% /c "lfn with space" parameter
 

rconn

Administrator
Staff member
May 14, 2008
10,101
85
#6
CMD.EXE has a fairly whimsical set of rules for deciding whether to strip or retain leading/trailing quote marks on its startup command line. Type CMD /?, hit Enter and then press the spacebar once to see the executive summary.

Should TCC.EXE emulate this Rube Goldberg behavior?

Actually, TCC does emulate most of the (bizarro) CMD behavior with multiple quotes (mostly in the wrong places) on the startup command line. This one particularly twisted syntax of quoting part of the command line and arguments (for no reason; it works fine without the quotes) is not supported. This is WAD; I decided long ago that this particular unnecessary syntax would create problems with supporting otherwise valid command lines.
 
Aug 16, 2008
124
0
#7
I'm running TCC v15.01.52 and I get expected behavior.
Code:
TCC: Not an alias "where"
Try running your command without the quotes:
Code:
tcc /c alias where
It's possible that the version of TCC you are running is trying to run "alias where" as opposed to ALIAS with an argument of "where".
-Scott
I don't run the command in quotes. That's FAR functionality. And it works without the plugin.
 
Aug 16, 2008
124
0
#8
Actually, TCC does emulate most of the (bizarro) CMD behavior with multiple quotes (mostly in the wrong places) on the startup command line. This one particularly twisted syntax of quoting part of the command line and arguments (for no reason; it works fine without the quotes) is not supported. This is WAD; I decided long ago that this particular unnecessary syntax would create problems with supporting otherwise valid command lines.
Is there any particular reason, why 'tcc /c "alias whatever"' works from a Take Command terminal but not when run via the Windows run dialogue? It also baffles me that 'tcc /k "alias whatever"' works (but not /c).
 
#9
Is there any particular reason, why 'tcc /c "alias whatever"' works from a Take Command terminal but not when run via the Windows run dialogue? It also baffles me that 'tcc /k "alias whatever"' works (but not /c).
That would depend on how and when you load your aliases. If they're always loaded (SHRALIAS is running and you use global aliases) or you *always* load them in TCSTART.BTM, both should work. If you exit TCSTART.BTM before loading aliases in transient (/C) instances then I'd expect the behavior you mention.
 
#10
Loading of aliases ought not to be relevant. As Scott showed, if the TCC command alias is executed at all, it would display either the Not an alias "where" error message, or expand the alias, instead of the actual error report indicating the quote marks having caused a syntax error: the whole command line being considered to be the command itself. I would think that this would cause havoc with externals (other executables) expecting parameters. Without having either ConEmu or the FAR plugin I cannot perform meaningful tests...
 
#11
I misunderstood his question. I do not see a difference. From the run dialog, both
Code:
TCC /K "alias whatever"
and
Code:
TCC /C "alias whatever"
result in
Code:
TCC: Not an alias "whatever"
Occasionally, in the second case, the console disappears so quickly that I don't see the output. It's easier to see if I
Code:
TCC /C "alias whatever" & pause