Skip to content

emcc doesn't work with filenames/paths with ! sign #14063

Closed

Description

@fgsgn-las

Trying to compile simple source file located in directory named "a!":

emcc.bat a!\a.cpp
emcc: error: a\a.cpp: No such file or directory ("a\a.cpp" was expected to be an input file, based on the commandline arguments provided)

Same with "!" in filename:

emcc.bat !!!a.cpp
emcc: error: a.cpp: No such file or directory ("a.cpp" was expected to be an input file, based on the commandline arguments provided)

Seems it just strips ! char from paths/filenames.

Activity

  1. sbc100 commented on May 2, 2021

    @sbc100
    Collaborator

    Given the correct quoting this seems to work for. At least on linux:

    $ touch a\!.c
    $ ls a*
    'a!.c' 
    $ emcc a\!.c -c
    $ ls a*
    'a!.c'  'a!.o' 
    

    It looks like maybe you are on windows.. maybe you need to escape the exclamation mark some how there too?

    Maybe try to open the file using notepad.exe from the command line.. so you know you have the escaping right.

  2. fgsgn-las commented on May 3, 2021

    @fgsgn-las
    Author

    Yes, we are using windows.
    Notepad opens files with such names without problems (I mean a!.cpp for example)

    If trying to escape chars, emcc shows the following result:
    emcc.bat a!.cpp
    emcc: error: a.cpp: No such file or directory ("a.cpp" was expected to be an input file, based on the commandline arguments provided)

    Following variants, that also used in windows, also doesn't work:
    emcc.bat "a!.cpp"
    emcc: error: a.cpp: No such file or directory ("a.cpp" was expected to be an input file, based on the commandline arguments provided)

    emcc.bat "a!.cpp"
    emcc: error: a.cpp: No such file or directory ("a.cpp" was expected to be an input file, based on the commandline arguments provided)

  3. sbc100 commented on May 3, 2021

    @sbc100
    Collaborator

    But I mean does notepad open from the command promt you are in ? What escape method do you use when opening from the command line using notepad.exe a!.cpp?

  4. fgsgn-las commented on May 5, 2021

    @fgsgn-las
    Author

    Notepad open even following:

    notepad a!.cpp

    No escape needed.
    I suppose emcc using their own filename handling.

  5. sbc100 commented on May 5, 2021

    @sbc100
    Collaborator

    emcc is using python's standard file handling.

    Can you trying running a trivial program like this?:

    $ python -c "import sys; print(sys.argv[1]); print(open(sys.argv[1]))" a!.cpp

    When I next get a chance use windows machine I can take a look myself.

  6. fgsgn-las commented on May 6, 2021

    @fgsgn-las
    Author

    Looks strange, because it works:
    > python -c "import sys; print(sys.argv[1]); print(open(sys.argv[1]))" a!.cpp
    a!.cpp
    <_io.TextIOWrapper name='a!.cpp' mode='r' encoding='cp1251'>

  7. sbc100 commented on May 12, 2021

    @sbc100
    Collaborator

    This seems to be related to out .bat files that launch python. If I run emcc via python emcc.py it works but if I run it via emcc.bat it fails:

    Works:

    $ python emcc.py a!.cpp -c
    

    Fails:

    $ emcc a!.cpp -c
    emcc a!.cpp -c
    emcc: error: a.cpp: No such file or directory ("a.cpp" was expected to be an input file, based on the commandline arguments provided)
    
  8. sbc100 commented on May 12, 2021

    @sbc100
    Collaborator

    It looks like #13723 is to blame. emcc a!.cpp -c works before that change an fails afterwards. @aheejin any ideas? This looks pretty nasty.

  9. sbc100 commented on May 12, 2021

    @sbc100
    Collaborator

    Looks like this is known issue with EnableDelayedExpansion:

    From https://ss64.com/nt/delayedexpansion.html:

    "
    If DelayedExpansion is used in conjunction with a FOR command looping through a set of files, if any file in the set has an exclamation mark '!' in the filename, that will be interpreted like a !variable!.
    Although this is not a common character used in filenames, it can cause scripts to fail. This happens because the parameter expansion (%%P) happens just before the delayed expansion phase tries to interpret my!filen!ame.txt
    "

  10. sbc100 commented on May 12, 2021

    @sbc100
    Collaborator

    Makes me want to look into maybe seeing if we can just assume powershell and run that from the .bat file.

  11. added 7 commits that reference this issue on May 22, 2021
    727ea19
    7b5ffd4
    d26def8
    f45fc85
    288465c
    a80525c
    926b653
  12. added a commit that references this issue on May 22, 2021
    4dfdf67
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions