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

Command name parsing of GNU compilers

Discussion in 'Support' started by nickles, Oct 6, 2016.

  1. nickles

    Joined:
    Jun 24, 2008
    Messages:
    220
    Likes Received:
    0
    Calling c++ or g++ from tcc.exe results in the following errors when either a batch file, or an alias with a shorter name (matching the command name before the "++") is defined:

    PROMPT> c++
    Usage: db [bcimp] (calls c.btm)

    PROMPT> g++
    fatal: Not a git repository (or any of the parent directories): .git (calls g, an alias)

    Otherwise (renaming the batch file, or unaliasing the alias) the compiler is called.
     
    #1 nickles, Oct 6, 2016
    Last edited: Oct 6, 2016
  2. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,869
    Likes Received:
    83
  3. nickles

    Joined:
    Jun 24, 2008
    Messages:
    220
    Likes Received:
    0
    That's a workaround, not a solution that is compatible with the behavior when there is no "c.btm" or no "g" alias. The program name is "c++" not "c". I think this is a parsing problem; having e.g. a "c.cmd" (or "c.bat" for that matter) in "c:\windows" doesn't prevent cmd.exe from starting "c++.exe".
     
  4. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,869
    Likes Received:
    83
    + is not a valid filename character. It's used for other purposes in the parser (for example, when appending files with COPY, and as a batch argument separator).
     
  5. nickles

    Joined:
    Jun 24, 2008
    Messages:
    220
    Likes Received:
    0
    I understand that. However, this breaks compatibility with cmd.exe which also supports "+" for "copy" (besides, AFAIK there is no "copy+<to_something>"). Wouldn't it just be possible to accept "+" as part of the first token in the command line?
     
  6. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,311
    Likes Received:
    39
    Could you alias around it, e.g.
    Code:
    alias c++="c++"
    
     
  7. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,869
    Likes Received:
    83
    CMD has a separate parser for every command, while TCC has a single parser for all commands. I think the latter is vastly preferable for the sake of uniformity (and not increasing the code size 10x). But if you want you could post something in the suggestion forum that TCC should adopt the CMD style (this would, however, break a LOT of existing functionality).
     
  8. samintz

    samintz Scott Mintz

    Joined:
    May 20, 2008
    Messages:
    1,191
    Likes Received:
    11
    It might be a lot easier to just rename the tool(s).
     
  9. MaartenG

    Joined:
    Aug 3, 2016
    Messages:
    355
    Likes Received:
    8
    Adding the file extension will also work: notepad++.exe (without quotes) works fine here

    Btw: Tab completion on the command-line already "knows" that filenames like this have to be quoted.
    My notepad++.exe gets expanded to "notepad++.exe" (with quotes) whereas notepadplusplus.exe gets expanded to notepadplusplus.exe (without the quotes)
     
  10. nickles

    Joined:
    Jun 24, 2008
    Messages:
    220
    Likes Received:
    0
    First of all: Thanks for your input.
    However: What about the highly-praised compatibility of tcc? What when it comes to executing batches with "unknown" content?
     
  11. gentzel

    Joined:
    Sep 24, 2013
    Messages:
    21
    Likes Received:
    0
    From the FAQ:
    Looks like you've found part of the 0.1%.
     
  12. nickles

    Joined:
    Jun 24, 2008
    Messages:
    220
    Likes Received:
    0
    @gentzel
    That's an argument you can use in either direction. (And in fact, it was already used by JPSoft to turn down other requests "this is not compatible with cmd.exe").
    Anyway, I take it that most of the guys on this forum are ok with the current implemention; well then - so will I.
     
  13. MaartenG

    Joined:
    Aug 3, 2016
    Messages:
    355
    Likes Received:
    8
    Turns out I was wrong about this. I defined a 'notepad' alias in another TCC box, but forgot it was a local alias. So, adding the file extension doesn't do the trick.

    I like the beauty of simplicity/consistency, but I don't think it is possible in this case:
    The most simple parsing rule would be: if not "space" before "+", the "+" is part of the filename/alias/..
    But .... CMD (and TCMD) supports a command like: copy 1.txt+2.txt all.txt (without spaces around the "+"). So it will be "messy" anyhow.

    Ergo:
    The carpet in the room is just too small to cover all the problems. If you fix the (CMD-) problems on one side of the room, you will uncover new problems on the other side of the room. And buying a complete new (handmade, expensive) carpet is not really an option.
    So in this case an extra piece of the same carpet was made and put in an unremarkable corner and stitched together with a few """ ...
    I can live with that (but I have to confess: I never have to be in that corner of the room :-)


    On the other hand: there is some strange "+"-related behaviour:
    - dir++ (without a space) gives you: The system cannot find the file specified. "C:\Temp\ff\++".
    - If + is not a valid filename character ([title] ), then why is echo something > "+++.+++" supported? (Or at least warn me that I'm being stupid).
    - echo something > one+two.txt needs too be quoted in TCMD, too (as expected)

    Out of curiosity: what will the parser do with external commands that have command-line options like /+4 (can't think of a real scenario or a good example)

    BTW: Isn't there some thread where the differences between CMD and TCMD can be logged? Couldn't find it.
     
    #13 MaartenG, Oct 7, 2016
    Last edited: Oct 7, 2016
  14. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,869
    Likes Received:
    83
    You can put all kinds of invalid filename characters in a filename if you double quote the name.

    TCC can't globally assume that a + is automatically part of a command name, as there are several internal commands where a trailing '+' is supported (and not part of the name).
     

Share This Page