frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Modernish – A library for writing programs for POSIX-based shells and utilities

https://github.com/modernish/modernish
76•sundarurfriend•6mo ago

Comments

pimlottc•6mo ago
This could really use a short, pithy code example at the start of the readme to show what it looks like. Otherwise, you have to get pretty far into the docs to see any actual commands, or click the example link which doesn’t display well on mobile.
lioeters•6mo ago
Comparison with Bash, from https://github.com/modernish/modernish/blob/master/EXAMPLES....

# Plain POSIX sh

    #! /bin/sh
    git status >/dev/null || exit
    if ! git diff-index --quiet HEAD; then
        echo 'Working dir not clean' >&2
        exit 1
    fi

    find . -name .git -prune \
    -o -exec sh -c '
        # Ask Git for latest commit'\''s timestamp,
        # formatted for POSIX '\''touch -t'\''.
        timestamp=$(git log --format=%cd \
          --date=format:%Y%m%d%H%M.%S \
          -1 HEAD -- "$1") || exit
        [ -n "$timestamp" ] || exit

        set -x
        touch -t "$timestamp" "$1"
    ' dummy {} \;

# Modernish

    #! /usr/bin/env modernish
    #! use safe
    #! use sys/cmd/harden
    #! use var/loop
    harden git
    harden -e '>1' -f wd_is_clean \
        git diff-index --quiet HEAD
    harden -pt touch

    git status >/dev/null
    wd_is_clean || exit 1 'Working dir not clean'

    total=0
    LOOP find repofile in . -name .git -prune \
    -or -iterate; DO
        # Ask Git for latest commit's timestamp,
        # formatted for POSIX 'touch -t'.
        timestamp=$(git log --format=%cd \
          --date=format:%Y%m%d%H%M.%S \
          -1 HEAD -- $repofile)
        str empty $timestamp && continue

        # 'touch' is traced by 'harden -t'.
        touch -t $timestamp $repofile
        let "total+=1"
    DONE
    exit 0 "$total timestamps restored."
johnthescott•6mo ago
in the example plain posix code seems more clear than modernish.
cb321•6mo ago
Their `use` shell function should really be `use1` and `use` should process its whole argument list. Then their opening example could be `use safe sys/base` and "dialect tweaking" can be just one line with the option but not requirement to be multiple lines. Just a thought.
amterp•6mo ago
Modern cmd line scripting is an interesting area and I like seeing people's different approaches to improving it. Personally, I want to get as far away from writing control flow, loops, etc in Bash as I can. I'm working on https://github.com/amterp/rad which is a CLI scripting language that takes a more Python-like approach, which people here might find interesting, though it serves slightly different cases than Modernish.
leonheld•6mo ago
It's all written in shell, no other dependencies. This is what so many shells that tried to "revitalize" sh missed! I'll definitely adopt this.
cmcconomy•6mo ago
I greatly appreciate these kinds of tools but I always err on the side of what's installed by default wherever possible so I can work across hosts as soon as i land
alterae•6mo ago
agreed. and the setup for this tool in particular looks… complicated and annoying, at least at first glance

for myself, if i want a shell script to be _portable_ i just write it in POSIX sh and try to be smart about dependencies

and if i don't care about portability, i'd rather just use a nicer shell like bash or zsh or fish (i'd actually like to mess with ysh at some point)

i feel like i'm much more likely to encounter a system with one of those shells available than one with modernish installed, and the idea of introducing a bundling/build step into shell scripts is deeply unappealing to me.

i can see why this exists, i think, and i imagine there are people who find it useful. i simply am not among them.

i also find it disappointing that their most basic example shows the setup in bash instead of sh, but that might just be me.

dataflow•6mo ago
I get wanting some level of portability, but what kind of systems do you still encounter (and want to run your scripts on) that have sh yet lack Bash? I would've expected that to be the baseline nowadays.
timeinput•6mo ago
For me it's small alpine containers running in k8s, and trying to get weird stuff running on my kobo ereader (can quickly get to a chroot with bash, but the base system doesn't have it).
lorenzohess•6mo ago
Perfect name!
jonathaneunice•6mo ago
Said with love: This is lipstick on a pig.

A very old and beloved pig, but still alas, a pig.

It's great to extend the shell idiom, to patch up its inconsistencies and unportabilites, to make it better. I love the progression of sh, csh, tcsh, ksh, bash, zsh, fish, and others. But it's also Sisyphean. At the end, you still have a shell experience not a programming language experience. And as long as we're talking about programming things, the full toolset will remain more direct, more powerful, more maintainable—and thus more apt.

I hate gol-lumping over the gap between a dashed-off Bash or Zsh script and the Python equivalent (say), but the full language has better semantics, typing, exceptions, modules, data structures, expressive power, and tooling. As the person who not only has to dash off the initial POC but extend and maintain it over time, and someone who's tried both routes, if there's any complexity at all—any datetimes, timestamps, or timezones to be wrangled; any complex JSON to be parsed out of an API; any significant parsing or concurrency to be managed—going to prefer the full tools every time.

RGBCube•6mo ago
Many such cases.

Nushell fixes this: https://nushell.sh/

I've been using it as my shell for 2-3 years, and it has improved a LOT since then. The interactive experience is great, and it's wonderful assembling scripts in its REPL. I can use my editor to edit the bufferline too using ctrl+o.

The best thing about it is that's it's self-contained. You don't have to assume anything about the users environment, as Nushell has almost everything you'd need fot common tasks built-in.

Some example scripts I've written:

- Link all files in a dir & deduplicate based on hash, in parallel, handling all cases: https://github.com/RGBCube/random-scripts/blob/master/linear... - A simple github->forgejo migration/live mirroring script: https://github.com/RGBCube/GitHub2Forgejo/blob/master/github...

All of these only need nushell, and not even coreutils.

PanelBench: We evaluated Cursor's Visual Editor on 89 test cases. 43 fail

https://www.tryinspector.com/blog/code-first-design-tools
1•quentinrl•2m ago•0 comments

Can You Draw Every Flag in PowerPoint? (Part 2) [video]

https://www.youtube.com/watch?v=BztF7MODsKI
1•fgclue•7m ago•0 comments

Show HN: MCP-baepsae – MCP server for iOS Simulator automation

https://github.com/oozoofrog/mcp-baepsae
1•oozoofrog•10m ago•0 comments

Make Trust Irrelevant: A Gamer's Take on Agentic AI Safety

https://github.com/Deso-PK/make-trust-irrelevant
2•DesoPK•14m ago•0 comments

Show HN: Sem – Semantic diffs and patches for Git

https://ataraxy-labs.github.io/sem/
1•rs545837•16m ago•1 comments

Hello world does not compile

https://github.com/anthropics/claudes-c-compiler/issues/1
2•mfiguiere•22m ago•0 comments

Show HN: ZigZag – A Bubble Tea-Inspired TUI Framework for Zig

https://github.com/meszmate/zigzag
2•meszmate•24m ago•0 comments

Metaphor+Metonymy: "To love that well which thou must leave ere long"(Sonnet73)

https://www.huckgutman.com/blog-1/shakespeare-sonnet-73
1•gsf_emergency_6•26m ago•0 comments

Show HN: Django N+1 Queries Checker

https://github.com/richardhapb/django-check
1•richardhapb•41m ago•1 comments

Emacs-tramp-RPC: High-performance TRAMP back end using JSON-RPC instead of shell

https://github.com/ArthurHeymans/emacs-tramp-rpc
1•todsacerdoti•45m ago•0 comments

Protocol Validation with Affine MPST in Rust

https://hibanaworks.dev
1•o8vm•50m ago•1 comments

Female Asian Elephant Calf Born at the Smithsonian National Zoo

https://www.si.edu/newsdesk/releases/female-asian-elephant-calf-born-smithsonians-national-zoo-an...
2•gmays•51m ago•0 comments

Show HN: Zest – A hands-on simulator for Staff+ system design scenarios

https://staff-engineering-simulator-880284904082.us-west1.run.app/
1•chanip0114•52m ago•1 comments

Show HN: DeSync – Decentralized Economic Realm with Blockchain-Based Governance

https://github.com/MelzLabs/DeSync
1•0xUnavailable•57m ago•0 comments

Automatic Programming Returns

https://cyber-omelette.com/posts/the-abstraction-rises.html
1•benrules2•1h ago•1 comments

Why Are There Still So Many Jobs? The History and Future of Workplace Automation [pdf]

https://economics.mit.edu/sites/default/files/inline-files/Why%20Are%20there%20Still%20So%20Many%...
2•oidar•1h ago•0 comments

The Search Engine Map

https://www.searchenginemap.com
1•cratermoon•1h ago•0 comments

Show HN: Souls.directory – SOUL.md templates for AI agent personalities

https://souls.directory
1•thedaviddias•1h ago•0 comments

Real-Time ETL for Enterprise-Grade Data Integration

https://tabsdata.com
1•teleforce•1h ago•0 comments

Economics Puzzle Leads to a New Understanding of a Fundamental Law of Physics

https://www.caltech.edu/about/news/economics-puzzle-leads-to-a-new-understanding-of-a-fundamental...
3•geox•1h ago•1 comments

Switzerland's Extraordinary Medieval Library

https://www.bbc.com/travel/article/20260202-inside-switzerlands-extraordinary-medieval-library
2•bookmtn•1h ago•0 comments

A new comet was just discovered. Will it be visible in broad daylight?

https://phys.org/news/2026-02-comet-visible-broad-daylight.html
4•bookmtn•1h ago•0 comments

ESR: Comes the news that Anthropic has vibecoded a C compiler

https://twitter.com/esrtweet/status/2019562859978539342
2•tjr•1h ago•0 comments

Frisco residents divided over H-1B visas, 'Indian takeover' at council meeting

https://www.dallasnews.com/news/politics/2026/02/04/frisco-residents-divided-over-h-1b-visas-indi...
4•alephnerd•1h ago•5 comments

If CNN Covered Star Wars

https://www.youtube.com/watch?v=vArJg_SU4Lc
1•keepamovin•1h ago•1 comments

Show HN: I built the first tool to configure VPSs without commands

https://the-ultimate-tool-for-configuring-vps.wiar8.com/
2•Wiar8•1h ago•3 comments

AI agents from 4 labs predicting the Super Bowl via prediction market

https://agoramarket.ai/
1•kevinswint•1h ago•1 comments

EU bans infinite scroll and autoplay in TikTok case

https://twitter.com/HennaVirkkunen/status/2019730270279356658
7•miohtama•1h ago•5 comments

Benchmarking how well LLMs can play FizzBuzz

https://huggingface.co/spaces/venkatasg/fizzbuzz-bench
1•_venkatasg•1h ago•1 comments

Why I Joined OpenAI

https://www.brendangregg.com/blog/2026-02-07/why-i-joined-openai.html
37•SerCe•1h ago•32 comments