Hacker News new | past | comments | ask | show | jobs | submit login
Ask HN: What shell do you use, if not *sh?
5 points by bmacho on Nov 11, 2022 | hide | past | favorite | 7 comments
I don't know bash. I don't want to know bash, I am not interested in a language that uses the program [ for if-branches. (Also I don't want pitfalls in the simplest possible tasks, thank you very much.)

I am looking for a shell language, with the following criteria:

    - fairly popular and alive
    - is small, like putting a binary in the /bin folder 
    - can start programs, support pipes, file operations 
    - has variables, if branches, lists, for loops, basic integer arithmetic, strings 
    - not POSIX compatible, or resembling to bash 
Google offers a handful of options, but I am interested if people actually use not bash or bash alike languages for shell scripting.



Not technically shell, but Python can get you fairly close to that.


You could try something like REXX (it was a popular choice in the Amigas, and is used extensively in IBM mainframes). I could also humorously suggest JCL, but nobody likes it. When I log in to Hercules, I end up in TSO, which can be called a shell. All these are as far from a POSIX shell as I can imagine.

You may find inspiration in other non-Unix OSs such as MCP (Unisys still supports it), or GCOS and GECOS, still supported by Atos. One would say they are user-hostile shells, but I prefer to think they are extremely selective about their friends. I can say I never made the cut for any of them.


For scripting on my Linux systems, including scheduled utilities, I use ABS a lot. It has been enjoyable and straightforward.

https://www.abs-lang.org/


I swear by zsh and bash, but fish shell may be your thing: https://fishshell.com/

There's also PowerShell for all the OSes. PowerShell is object-oriented, well-dcumented, and quite different from POSIX shells: https://learn.microsoft.com/en-us/powershell/scripting/insta...


Most of my shell scripts are in JavaScript. It meets most of your requirements, as well as having good support for async behavior. I'll use node for simple scripts and deno if I want to compile to an executable or if it just feel like it.

The language doesn't have native pipes, but I'll sometimes include them in a command string `const output= exec("firstcommand ${somevariable} | secondcommand")`

As an added bonus you have access to the npm ecosystem.


You are right to see the poor interface and protest, but I would encourage you to understand why *sh is probably one of the most widely used tools in the industry before dismissing it. Unix Philosophy is a pretty interesting (and quick) book that is definitely worth reading. Before you reject bash, I would strongly recommend reading that book.

If you are using large amounts of ifs and fors or doing anything but basic arithmetic, you are probably not using bash idiomatically resulting in the feeling of hammering a screw. It's not that the hammer is a bad tool, so much as it is wrong tool for the task. The bash idiom for writing a complex shell script is write a python program and call it.

Almost all infra devs in the valley will use bash, zsh, or fish and then write a python program once a task is mildly complex.

> not POSIX compatible

What do you mean when you say this?

Bash is worth understanding, you can do extremely complex things with pretty minimal effort. It's generally less verbose and therefore quicker and easier to read. It generally discourages complexity. There are many default behaviors that make many tasks easier and less boiler-plate-y. Autocomplete in shell is very efficient and doesn't require the overhead of an IDE. If for no other reason, you should spend a day or 2 learning bash because if you do any serious level of administration you will definitely run into bash shell scripts and it's worth knowing the pitfalls of bash if you need to fix/edit them. Sometimes git repos will have shell scripts for various purposes embedded in them as well.

xargs is one of the most beautiful programs I've ever used. It is probably the most low effort parallelism that exists in software.

With bash, it's relatively simple to ssh into a list of machines, then grep through all of their log files for a hash (maybe a request id or a specific IP). You could even ssh and then sum the number of 500's and then sum the number of 500's from each of the individual machines.

You can do impromptu map-reduce style operations with extreme efficiency on arbitrary data sources.

If I were interviewing a person and they didn't know bash or thought it was a bad tool I would take that as a major red flag. I have even been asked bash adjacent questions (questions that require understanding, not programming) in interviews from bigtechcos.

BTW, there are books like programming ruby and more interestingly meta-programming in ruby that make "[ for if-branches" look like child's play. Many domain specific languages do all types of crazy stuff.


I’d use fish if my bash scripts would work in it. Looks awesome




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: