back
33 comments
Author here.

My main use for this is incremental migration away from bash. I'm not saying this is the best way to do scripts, but it's a pretty great stepping stone. Just following the cargo culting guide [0] can already uplift a bash script without changing the logic too much. From there you can start adding structure.

My secondary use case is little scripts in NixOS/nixpkgs. There are some helpers in there that make it quite convenient.

[0] https://github.com/luke-clifton/shh/blob/master/docs/porting...

Those of you who use (or used) this as your shell: care to share your experience?

It seems a lot less full-featured than https://xon.sh/, but maybe you don't need a lot of bells and whistles for regular usage. I mostly run build, execute, and install commands.

I'm somewhat enticed at the possibility of being able to wrap common executables into forms that are typed (like nushell or elvish) and manipulate them in a way that leverages the type checker.

Author here. I rarely use it as a shell personally, though it does work, and sometimes I drop into it for the odd task. It's primarily designed to replace overgrown bash scripts.
shh is a really cool package, and so is turtle and shelly:

https://hackage.haskell.org/package/turtle/docs/Turtle-Tutor...

https://hackage.haskell.org/package/shelly

shh's "Alternatives" section summarises nicely some of the differences between these:

https://github.com/luke-clifton/shh#alternatives

shh has a neat [fmt| ... |] macro that gets you around escaping strings.

shh generally has more Template Haskell support; you may or may not like this.

I am personally leaning towards shh because of its "native pipe style".

> shh has a neat [fmt| ... |] macro that gets you around escaping strings.

Per the README, this is actually the work of https://hackage.haskell.org/package/PyF

Related: has anyone tried scheme shell (scsh) and what is your experiences with it?

https://en.m.wikipedia.org/wiki/Scsh

FWIW there is a big list of similar libraries / internal DSLs in nearly all Lisps, and nearly all statically typed functional languages here:

https://github.com/oilshell/oil/wiki/Internal-DSLs-for-Shell

e.g. points to another Haskell project, which may be old - https://github.com/jgoerzen/hsh/wiki

Which is related to the list of free-standing shells:

https://github.com/oilshell/oil/wiki/Alternative-Shells

There is also Rash: Racket Shell that looks súper interesting.

https://youtu.be/yXcwK3XNU3Y?si=XuABEBZReyfhraAh

Haven't tried it though.

It is interesting, but not something you’d really want to rely on. (see the issues, comments and commit history: https://github.com/willghatch/racket-rash)

This project could really benefit from picking up a couple of steady contributors. It looks like the author is a new dad, and his commit history looks about like what mine did at that stage.

Interestingly Rash is also suitable as a user-oriented shell (like bash) rather be reserved for scripting (like scsh).
Last time I tried I couldn't get it to compile

These days https://babashka.org/ is a much better option. It's powerful, fast, modern, works everywhere and has effortless multitasking.

IMHO it's worth spending some time getting acquainted with it. It's very clearly thought out conceptually with good separation of concerns. I learned a lot about Scheme and a lot about Unix from using it.
Not this one, but for a while I tried getting

https://wryun.github.io/es-shell/

to run (a functionalish shell)

"Shell scripts" is kinda the domain of newLISP, which I've used before and like.
Thanks for the answers, guys.
This seems fun! Far too few people who are all "your bash scripts shouldn't be 300 lines and have complex logic!" address why people reach for bash scripts in the first place, so kudos for that.
You can’t really move away from bash, unless there would be alternative as widely available on different Unix systems as bash is.

Yes, you came up with a nice syntax for your Haskell scripts, but what it cost to install all required dependencies on, for example, newly created Ubuntu server?

It's pretty easy if you use NixOS :)

That's been one of the somewhat unexpected benefits for me with NixOS: it's so easy to pull in tools and libraries that I don't have to worry about using less popular options.

Are you kidding? Half of NixOS is written in bash.

Nixpkgs is just Nix used as a metalanguage for splicing together bash object language programs.

Guix is what it looks like when you really get away from bash -- they use scheme as both the metalanguage and the object language.

The caveat is that you're pushing the complexity somewhere else. I'm finally moving away from NixOS this month (after two years of using it) because I'm tired of edge casing interrupting my daily flow.
> You can’t really move away from bash, unless there would be alternative as widely available on different Unix systems as bash is.

Lua can be built from source in a few seconds on just about any system and can be used pretty easily as a bash replacement. You can even bundle the lua script in a bash script that idempotently installs lua and then calls the lua script embedded in heredoc.

Yep, this is mainly used for turning those bash scripts that you let get too large into a real program. You port your script, basically line for line, into this, and then start chipping away at it until you have something less scary.
You’re not always working in crummy environments. Sometimes you can have nice things (if you think this is nice).

I don’t get the impression that this is supposed to be the final solution to Bash.

We're trying to do a similar thing with darklang right now: providing a single binary with a built-in package manager. The idea being making it easy to write readable "bash" scripts (including writing them with AI), but with just one dependency - the darklang binary itself.
Yes, but Shh works on Windows. And on OS X you need to install about the same things if you want to have a recent Bash

    > /bin/bash --version
    GNU bash, version 3.2.57(1)-release (arm64-apple-darwin23)
    Copyright (C) 2007 Free Software Foundation, Inc.
Why do you want to develop Haskell programs in a newly created Ubuntu server? Or do you want to compile it down at the deployment target?
I’m missing something — why would a newly created Ubuntu server be any better or worse than any other system for developing Haskell?
There has been a couple of decades since I last had to do any development in a newly created server.

Development is best done on well setup workstations.

Too bad Hugs98 (installation is few MBs) is no longer updated leaving only GHC (GB+).
You don't need the compiler to run the program in production. You only need the binary. I'd argue that a heavy toolchain in the dev machine isn't a big deal.
Bash scripts tend to be used in situations where you want to edit them and not have to deal with a recompilation step, let alone a multi-GB compiler install. That seems like a deal-breaker to me.

The best alternative I've found so far is Deno. It natively supports single file scripts with third party dependencies (this is a big issue with replacing Bash with Python). It uses an existing popular language (so now "learn our weird language" problem). Installation is very easy.

The only real downside I've found is this stupid bug that they refused to fix:

https://github.com/denoland/deno/issues/16466

That is a very good point in favor of Bash.
Huh, I was just tinkering with the same sort of thing with the same motivations but with F#:

https://github.com/williamcotton/fs_playground/blob/main/Scr...

Thanks for this, I’m going to borrow a lot of your concepts, especially the added infix operators, those are slick!