GithubHelp home page GithubHelp logo

matveyt / shebang Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 2.0 46 KB

A small helper for MSYS2/Cygwin that allows direct execution of shell scripts by Windows applications.

License: BSD 2-Clause "Simplified" License

C 92.59% Makefile 2.79% Meson 4.62%
posix shebang msys2 cygwin

shebang's Introduction

shebang

Summary

An utility for MSYS2/Cygwin which allows to execute POSIX shell scripts transparently.

Description

MSYS comes with its own port of bash which is able to execute shell scripts. However, unlike ported binaries, no POSIX shell script can be executed directly from the native Windows command-line interpretator cmd (or from other Windows programs, such as FAR, etc.).

It's quite easy to come up with the "wrapper script" solution, for example:

@rem shebang.cmd
@env MSYSTEM=MINGW64 %~n0 %*

will execute any POSIX script (or native binary) called "shebang" found on PATH. However, any (incorrectly ported) application will fail if it tries to execute such script by spawning it directly, which is normal for the POSIX world, but not for Windows, where one needs to provide an explicit command, such as cmd /C shebang.cmd. This is where shebang comes to help.

Building

Shebang was successfully built and tested with GCC/MSYS2 10.2.0.

There is a meson project script provided with the distribution. You will need meson, python3 and ninja to make use of it.

However, shebang could be also compiled in the command line. For example, gcc -s shebang.c -o shebang.exe -lshlwapi works just nice.

The additional DEFINEs to control the building process are:

-DUNICODE
-DNOSTDLIB

UNICODE is needed to build the "wide" version of an executable.

NOSTDLIB is useful for reducing the size of an executable by linking it with a custom startup code, such as nocrt0.

Using

Simply rename or symlink shebang, so its name matches the script you want and put it on PATH. Now upon execution shebang will find the script on PATH, parse its first (aka "shebang") line, and execute it with own command-line arguments.

shebang's People

Contributors

matveyt avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

shebang's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.