Bashing the Bash – Replacing Shell Scripts with Python

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • sh

    Python process launching

  • On the contrary, I am 100% open to suggestions that BASH sucks. (Personally, I would have picked the inadequacies of `set -e` as my favorite ... unfortunate aspect.) My objection was very narrow: this specific article does a poor job at saying why shell sucks, and a worse job still at presenting Python as a superior alternative. That's not to say that good reasons to use something else don't exist, and it's not even to say that python can't be that alternative. (Your sibling comments suggesting xonsh and https://amoffat.github.io/sh/ paint a fairly compelling way to actually move to python without losing the advantages of shell, for instance.)

  • bashttpd

    A web server written in bash

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
  • PiBluetoothMidSetup

    Turn a raspberry pi into a Bluetooth Midi device

  • That's basically what I did with this project.

    https://github.com/Mylab6/PiBluetoothMidSetup

    Of course I could of done this in bash, but Python is just so much cleaner.

  • xonsh

    :shell: Python-powered, cross-platform, Unix-gazing shell.

  • > I was hoping someone finally had a library or something to make python good at the things shell does well (mostly, running stuff and piping output around). If only.

    xonsh (https://xon.sh/)

    Been using it for a few years now. It's worth it.

  • subb

    a wrapper module for python subprocess

  • I wrote this to simplify just that for my own tools; the subprocess module that comes with the batteries has a very general interface, i think that it is a bit complex for a quick script.

    https://github.com/MoserMichael/subb

    https://pypi.org/project/subb/

    Python doesn't have the problem of shell scripting language, it doesn't get impractical, as the program is getting more complex. In bash you have arrays, and even maps, but these aren't pretty. Also the shell scripting language is being evaluated by an parse tree/AST interpreter, that's significantly slower than even python, in it's byte code interpreted form.

    My objective was to get an abstraction, for a one line process run and extraction of the result, similar to what we had in Perl5 with the system library function. https://perldoc.perl.org/functions/system

    Also the shell is impractical, when it comes to slightly more complex programs. There is a limit on what you can do with pipes. Maybe that's the reason why perl is that flexible, as they tried to bridge both realms: Perl had to be useful as a replacement for the quick shell like script, and to be useful as a general purpose programming language.

  • Bash-web-server

    A purely bash web server, no socat, netcat, etc...

  • > For example, there is an implementation of an HTTP daemon written purely in bash[2]. Once again-- terrible idea, but great execution.

    It's not pure bash, as it relies on netcat or socat plus some external programs (ls, tree, cat, date).

    There does exist a pure bash httpd though. It relies on a loadable builtin (from the bash tree though not built by default).

    https://github.com/dzove855/Bash-web-server

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts