Create Linux Bash and Windows batch scripts simultaneously with Batsh

Mixed Doubles

© Lead Image © andreykuzmin, 123RF.com

© Lead Image © andreykuzmin, 123RF.com

Article from Issue 171/2015
Author(s):

Batsh kills two birds with one stone: Programs written in this language can be compiled both as Linux Bash scripts and Windows batch files.

Linux users like to use Bash scripts to automate repetitive tasks. In the Windows world, batch (.bat) files are used in the same way. However, the commands used in Linux and Windows scripts are often significantly different. Those who work in both Linux and Windows environments therefore not only have to create and maintain two separate scripts, they also have to grapple with various cryptic instructions.

However, this situation should end soon. Google employee Carbo Kuo, a Chinese native living in Switzerland, is currently working on a programming language called Batsh, whose code is translated by a compiler into the appropriate Bash or batch script.

Welcome Ritual

The following line in Batsh will suffice to output the popular message Hello world!:

[...]

Use Express-Checkout link below to read the full article (PDF).

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Bash Alternatives

    Don't let your familiarity with the Bash shell stop you from exploring other options. We take a look at a pair of alternatives that are easy to install and easy to use: Zsh and fish.

  • SHC: Bash Script Compiler

    The Bash Shell Script Compiler converts shell scripts directly into binaries. Compiling your scripts provides protection against accidental changes, but you will have to contend with some quirks.

  • How Does ls Work?

    A simple Linux utility program such as ls might look simple, but many steps happen behind the scenes from the time you type "ls" to the time you see the directory listing. In this article, we look at these behind-the-scene details.

  • Bash Tuning

    In the old days, shells were capable of little more than calling external programs and executing basic, internal commands. With all the bells and whistles in the latest versions of Bash, however, you hardly need the support of external tools.

  • Bash vs. Vista PowerShell

    Microsoft’s new PowerShell relies on .NET framework libraries and thus has access to a treasure trove of functions and objects. How does PowerShell measure up to traditional shells like Bash?

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More

News