Menu

#1985 MSYS can't find script without file extension in PATH

MSYS
closed
nobody
None
Support
self-service
User_Error
False
2013-06-07
2013-06-07
Basil Peace
No

I experience a problem with MSYS.

Background:
I'm trying to build some projects under MSYS. Currently, I've checked out GNU config (http://savannah.gnu.org/projects/config) and try to make check. All tests are failed.

Tester creates a faked uname in current directory, which should provide test samples. Current directory is added to PATH.

Problem:
Running uname, config.guess should pick up that one from current directory. However, this doesn't happen, and standard MSYS's uname is executed.
If I rename uname in current directory to uname.exe, MSYS recognizes it, but can't execute, since it expects different format.
I've also tried to play with PATHEXT environment variable, but it looks like MSYS doesn't use it at all.

And, then, I can't understand how MSYS's own scripts named without extensions (for example, automake) are executed? Is this behavior immutably encoded in source?

Is there any acceptable workaround besides compilation of tests to executable files?

Discussion

  • Keith Marshall

    Keith Marshall - 2013-06-07

    If I rename uname in current directory to uname.exe, MSYS recognizes it, but can't execute, since it expects different format.

    That's because any .exe file (by name) is expected to be in pe-coff format, and is invoked via the native windows loader; when the format isn't pe-coff, that loader will choke.

    Your uname is, I guess, a script. Does it have a valid shebang line? With a valid interpreter path name? That's what MSYS uses to identify scripts that it can process directly, using the specified interpreter.

    I've also tried to play with PATHEXT environment variable, but it looks like MSYS doesn't use it at all.

    This doesn't come into play, until MSYS has given up on identifying the command file type, and punts it to the native $COMSPEC interpreter.

    And, then, I can't understand how MSYS's own scripts named without extensions (for example, automake) are executed? Is this behavior immutably encoded in source?

    Nope. It simply relies on the script having a valid shebang.

    Is there any acceptable workaround besides compilation of tests to executable files?

    Bourne shell scripts should be fine, as long as they have valid shebangs.

     
  • Earnie Boyd

    Earnie Boyd - 2013-06-07
    • status: unread --> open
     
  • Earnie Boyd

    Earnie Boyd - 2013-06-07

    Also, make sure that . is the first item of $PATH; which is the default for MSYS if you installed it correctly or haven't modified it in your ~/.profile file or elsewhere.

     
  • Basil Peace

    Basil Peace - 2013-06-07

    Thank all of you for fast answer.
    I haven't ever thought about shebang line. Valid shebang has solved a problem.
    I just wonder how it could be workable in Linux without shebang line.

    Please close this issue as solved.

     
  • Earnie Boyd

    Earnie Boyd - 2013-06-07
    • status: open --> closed
    • Resolution: none --> self-service
    • Category: Unknown --> User_Error
     
  • Earnie Boyd

    Earnie Boyd - 2013-06-07

    With Linux you can mark the script executable and the default /bin/sh kicks in. With MSYS the #! on line 1 column 1 is the indicator for an executable script since the chmod semantics doesn't really work with the underlying OS except for read and write.

     
MongoDB Logo MongoDB