Bash on Windows: The scripting game just changed

March 31st, 2016 | Categories: Linux, RSE, Windows | Tags:

Yesterday saw the biggest highlight in the technical calendar so far for me… Microsoft has brought the Linux command line to Windows.

Excited by the command line

OK, so I’ll admit it….improvements to command line tools seriously excite me! Windows 10 brought in a couple of minor improvements to the command line last year and I acted like it was a second birthday. Imagine then, the excitement I felt while watching Microsoft’s announcement of linux integration into Windows (Spin to 2:24 to see it). I could barely form sentences! When my wife came into the kitchen to see what the commotion was, all I could manage was “Bash! On Windows!….GIT! OMG! Not a VM! vi..sed..awk…gcc! OMG!’

So why so much excitement?

Shell scripts are more than mere automation, they are repositories of knowledge  – they do some task for you and also explain how that task is done. They are wonderful things that can educate, take the drudgery out of a researcher’s life and lead to more reproducible research. The problem is that Linux and Mac users speak a different scripting language (Bash) to Windows users (Windows batch or more, recently, PowerShell).

In short, a script written on a Linux or Mac machine wouldn’t run on a Windows machine unless you jumped through some hoops.

Bash just became a cross-platform scripting solution

Various solutions for running Bash scripts on Windows have existed for a while. Cygwin, for example, compiles linux tools to run on Windows which works very effectively for many situations. Additionally, the Windows version of git comes with an emulated Bash mode that’s good enough to teach the scripting lesson from Software Carpentry. Neither of these solutions are perfect, however, and to me they’ve always felt like slightly awkward patches. The resulting binaries in projects such as Cygwin are necessarily different from those used in Linux Land.

This new collaboration between Canonical and Microsoft changes the game! Now, Linux tools appear like first-class citizens in the Windows world. When you run Bash on Windows, it will be the exact same Bash that’s run on Linux. An automated research analysis developed on a Linux machine will work exactly the same way on Windows.

The same skills apply, from tablet to supercomputer

Furthermore, when we teach introductory shell scripting to researchers we will be teaching them tools that allows them to work on all operating systems and all hardware types.

The same skills will apply to Mac, Linux and Windows from tablets to High Performance Computing clusters and that’s a wonderful thing.

 

  1. Ian
    March 31st, 2016 at 13:26
    Reply | Quote | #1

    As far as I can tell, this is exactly no different to cygwin: all they’ve done is added a layer to the kernel that translates Linux system calls into windows kernel instructions. Isn’t this exactly what cygwin/mingw does? Although they do seem to have a full linux system running on windows 10, no one has said that it is binary compatible as far as I can tell (but i might be wrong). The other thing no one has mentioned is if things like X11 applications or weird filesystems (such as sshfs) integrate seamlessly.

  2. Mike Croucher
    March 31st, 2016 at 15:36
    Reply | Quote | #2

    This link http://blog.dustinkirkland.com/2016/03/ubuntu-on-windows.html says

    ‘Hum, well it’s like cygwin perhaps?” Nope! Cygwin includes open source utilities are recompiled from source to run natively in Windows. Here, we’re talking about bit-for-bit, checksum-for-checksum Ubuntu ELF binaries running directly in Windows.’

    That sounds like binary compatible to me.

  3. Ian
    March 31st, 2016 at 16:18
    Reply | Quote | #3

    Fair enough, that does sound like binary compatibility. Which is really quite extraordinary when you consider that two linux distributions are often not binary compatible.