Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

How to? ,prog.py -a ignores -a

Jun
5
0
On my system, the extension .py is associated with python

If I run
Code:
 ,prog.py -a
in 4nt, it runs prog.py with the parameter -a, as if I had typed
Code:
python prog.py -a

However, if I do the same in tcc le 14.00.3, it ignores the parameter -a and acts is if I had just typed
Code:
python prog.py

Oddly (to me), if I create an alias
Code:
alias prog prog.py
and then type
Code:
prog -a
then the -a is passed along to the program

How do I make tcc behave like 4nt and pass along the parameter when the line starts with a comma?
 
Is the comma part of the file name? Did you try quoting it? e.g. ",prog.py" -a
I have the following executable extensions defined:
Code:
.py=C:\Python27\python.exe
.pyw=C:\Python27\pythonw.exe
.py[co]=C:\Python27\python.exe

So I don't need to specify the .py extension to run it.
prog -a
is the same as :
c:\python27\python.exe prog.py -a
is the same as:
prog.py -a
 
The comma is not part of the name. The advantage of a leading comma is that tcc will do tab file completion, so that I only need to type
Code:
,pr<tab>
and tcc will fill in prog.py.

Under 4nt, if I ran anything with a leading comma, it would run the command line with the associated program. As a random example,
Code:
,pic.jpg
would display pic.jpg using the jpg viewer windows associates with files with the jpg extension.

tcc does the same thing, except it only passes along the characters up to the first space, rather than the complete command line. I'm trying to figure out how to cause tcc to pass along the complete command line. Put another way, I'm trying to get tcc to do what 4nt did.

Quoting doesn't help.
Code:
,"prog.py -a"
gets
Code:
TCC: unknown command "prog.py -a"


How have you specified
Code:
.py=C:\Python27\python.exe

Is this part of windows file extension associations or is it something you've done in tcc?

FWIW, when I type
Code:
assoc .py
I get
Code:
.py=Python.File
and
Code:
ftype Python.File
gets
Code:
Python.File="c:\program files\python27\python.exe" "%1" %*
 
Last edited:
You don't quote the arguments. I usually use a space to get filename completion. If you set up python as an executable extension, it will autocomplete without the comma or space. Look up "Executable extensions" in the help.
 
That fixed the issue with python. Thanks!

There's still the general issue with programs for which I haven't set up executable extensions, but I suppose I can deal with those one by one when the need arises.
 
I have always used <space> to get completion. Does the comma have any advantage or disadvantage compared to <space>?
 
I have no idea about comma v. space. I used a comma as the first character when I used 4nt, so I was just blindly continuing to do so.
 
Reading the docs regarding Executable extensions and Windows File Extensions, it's not clear to me why executable extensions and windows extensions don't behave the same (other than the means of setting them).

In other words, if I've associated .py with a windows file type and that files type with python.exe, why should I also have to set .py=python.ext in tcc?

The only difference I've found is that I have to include the set command in tcstart.btm if I want it to persist.
 
I think the executable extension gives you completion, without a space or comma.
 
In other words, if I've associated .py with a windows file type and that files type with python.exe, why should I also have to set .py=python.ext in tcc?

You don't. The system already knows how to handle .py files the right way (if you type the command in full, it will fire Python, even without executable extensions)
What doesn't work in that case is tab completion. In TCC "unuseful" filetypes are skipped, so you don't have to tab through all these.
You can simply mark an extension as "useful" by adding it to the PATHEXT environment variable, like:
Code:
set PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.BTM;.TXT;.PY

After you enable the PATHEXT functionality (OPTION command > Startup tab > tick the PathExt box ), you can now type PR and <TAB> to get "prog.py" on the command-line..
 
Back
Top