1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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

Discussion in 'Support' started by quark, Jun 2, 2017.

  1. quark

    Joined:
    Jun 2, 2017
    Messages:
    5
    Likes Received:
    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?
     
  2. samintz

    samintz Scott Mintz

    Joined:
    May 20, 2008
    Messages:
    1,190
    Likes Received:
    11
    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
     
  3. quark

    Joined:
    Jun 2, 2017
    Messages:
    5
    Likes Received:
    0
    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" %*
     
    #3 quark, Jun 2, 2017
    Last edited: Jun 2, 2017
  4. samintz

    samintz Scott Mintz

    Joined:
    May 20, 2008
    Messages:
    1,190
    Likes Received:
    11
    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.
     
    quark likes this.
  5. quark

    Joined:
    Jun 2, 2017
    Messages:
    5
    Likes Received:
    0
    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.
     
  6. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,959
    Likes Received:
    30
    I have always used <space> to get completion. Does the comma have any advantage or disadvantage compared to <space>?
     
  7. quark

    Joined:
    Jun 2, 2017
    Messages:
    5
    Likes Received:
    0
    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.
     
  8. quark

    Joined:
    Jun 2, 2017
    Messages:
    5
    Likes Received:
    0
    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.
     
  9. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,959
    Likes Received:
    30
    I think the executable extension gives you completion, without a space or comma.
     
  10. MaartenG

    Joined:
    Aug 3, 2016
    Messages:
    355
    Likes Received:
    8
    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..
     

Share This Page