Skip to content

Modern Shell Language is a language and compiler for writing portable, complex shell scripts.

License

Notifications You must be signed in to change notification settings

philiparvidsson/Modern-Shell-Language

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Modern Shell Language

mshl is a language for performing automated shell tasks. It is similar to JavaScript in its syntax and compiles to Windows batch files (a bash target is planned!). This gives you the freedom of modern syntax and language functionality, allowing you to write much more complex programs that run on Windows and Linux without requiring the end user to install any extra piece of software.

Getting Started

  1. Download and install Python 2.7.x.
  2. Write a program in mshl or download one of the examples.
  3. Compile the program with mshlc by invoking it with Python (make sure you are in the correct directory first!): python mshlc filename.js

Depending on your platform, you will have a file named <filename>.bat in your current directory. It is the compiled shell script, ready to be deployed and executed on any system. The system that you deploy the program on will not require any software installation—a mere copy of the compiled script file is required.

Prerequisities

Installing

Begin by downloading and installing Python 2.7.x.

On Linux, depending on your distribution, Python comes pre-installed. This means that you do not need to install anything for mshl to work. If you don't have Python (you can check by typing python in a terminal), you might be able to install it by typing sudo apt-get install python.

On Windows, you need to install Python manually. See this link for more information.

Download the latest mshl release.

The latest mshl binary is always available from here. Download and save it to a directory on your computer.

Compiling

Write a simple (or very complex!) program in mshl.

To familiarize yourself with mshl, you can begin by writing a simple test program. You could also use one of the example programs, or the one below if you just want to try mshl out quickly:

include('stdio.js')

s = userinput("what's your name? ")
println('hey, ', s, '... oh, and hello world')

Mshl is able to compile very complex programs, generating advanced shell scripts performing tasks unthinkable in hand-written shell scripts!

Compile your program.

Save your program in a file and compile it with mshlc by invoking it through Python. Let's say, for example, that you saved the example code above in a file named myprog.js. You can then compile it by invoking mshlc in the following way: python mshlc myprog.js

Make sure you have the mshlc binary in the current directory!

Running the Tests

Run the tests by executing python runtests.py in the srcdirectory. All tests in the tests directory will be built and run automatically, ending with a report of passing and failing tests, as well as how much time it took to run them.

Deployment

Deploying the compiler

Deploying the mshl compiler is a matter of downloading the mshl binary. The compiler is then invoked with Python by typing python mshlc <srcfile>, which will generate a shell script for the target platform.

Deploying compiled programs

Programs compiled with mshlc are shell scripts that run on their target platforms without requiring the installation of any software. Simply transfer the compiled script to the target system and run it!

Built With

  • Emacs - The best text editor out there! ;-)
  • Python - A widely used high-level, general-purpose, interpreted, dynamic programming language.

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License—see the LICENSE.md file for details.

Acknowledgments

  • Some of the tests in the test suite were taken from Batsh to improve compatibility.
  • Thanks to batch scripting for being painful enough to inspire this project.

About

Modern Shell Language is a language and compiler for writing portable, complex shell scripts.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published