frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

Open in hackernews

Moreshell tricks: first class lists, jq, and the es shell

https://alurm.github.io/blog/2025-08-07-first-class-lists-in-shells.html
24•alurm•5h ago

Comments

jeffrallen•4h ago
I review shell scripts from beginner ops people. I would not approve any of this stuff. Once you need this complexity in shell, you need other things you should be getting from the language's stdlib. So I'd ask them to switch to Python or Go.

Do not fall into the trap of big complex shell scripts.

zhouzhao•3h ago
>Do not fall into the trap of big complex shell scripts

This so much.

SoftTalker•3h ago
There's a point where what you say is true but I would not view using 'jq' to tease a list out of some JSON data to be it. Isn't that what your python or go code is going to do? All jq is is a packaged set of calls to stdlib stuff.

Systems admins are generally not Python or Go experts. And those are two dependencies which may not be available anyway (or will require installation, and maintenancee, may introduce new vulns, etc.). You could say the same about 'jq' though.

calmbonsai•1h ago
I'll go further.

Shell is great for personal or local-group/team automation, but outside of a bootstrap, it should _never_ be used for anything in deployed production.

The 3 main issues are hidden deps, error handling, and performance.

delta_p_delta_x•3h ago
I was about to comment with my usual 'why not PowerShell', but it seems the author acknowledges this anyway at the end:

> I’ll quote Rich’s sh (POSIX shell) tricks to end this:

> I am a strong believer that Bourne-derived languages are extremely bad, on the same order of badness as Perl, for programming, and consider programming sh for any purpose other than as a super-portable, lowest-common-denominator platform for build or bootstrap scripts and the like, as an extremely misguided endeavor

alurm•3h ago
Yeah, PowerShell and nushell are pretty cool, I hope they gain more adoption.
stouset•2h ago
I keep intending to give nushell a serious try, but I'm too set in my ways :(
packetlost•1h ago
This is why I use Plan9's rc shell for a lot of my scripting needs. It's dramatically nicer to write but even more nice to read.
its-summertime•2h ago
with bash namerefs, having a function like

    split-on-ddash outputa outputb a b c -- x y z
    for x in "${outputa[@]}"; do # ...
becomes feasible. Of course, don't do it.
alurm•2h ago
Sure.

I have tried Bash namerefs. I found them to be kinda awkward, since you need to name them uniquely. So, you have to pretend that they are global variables, even though they are declared inside a function, which makes their usage verbose.

Here, this could look like:

  split_by_double_dash() {
    declare -n split_by_double_dash_before=$1
    declare -n split_by_double_dash_after=$2
    
    split_by_double_dash_before=()
    split_by_double_dash_after=()

    ...
  }
chubot•2h ago
let’s implement split-by-double-dash, a function (or a program) that would return two lists: args that come before -- and ones that come after.

split-by-double-dash a b c -- d e f should return the lists [a, b, c] and [d, e, f]

FWIW in YSH (https://oils.pub/ysh.html), you can do this in a style that's like Python and JavaScript, but you can also combine it with shell idioms.

First create it and pretty print it:

    ysh-0.34$ var li = :| a b c -- d e f |  # shell word style, ['a', 'b'] style is also accepted

    ysh-0.34$ = li  # pretty print with =
    (List)  ['a', 'b', 'c', '--', 'd', 'e', 'f']
Then test out the indexOf() method on strings:

    ysh-0.34$ = li.indexOf('--')
    (Int)   3
Then write the function:

    ysh-0.34$ func splitBy(li) {
            >   var i = li.indexOf('--')
            >   assert [i !== -1]
            >   return ( [li[ : i], li[i+1 : ]] )  # same slicing as Python
            > }
Call it and unpack it

    ysh-0.34$ var front, back = splitBy(li)

    ysh-0.34$ = front
    (List)  ['a', 'b', 'c']
Use it in shell argv, with @myarray as splicing:

    ysh-0.34$ write -- @back
    d
    e
    f
alurm•47m ago
YSH looks very nice here, thanks. I thought to mention YSH, but have no experience with it, so I hoped you would comment.

(I guess we're duplicating threads at this point :D)

kjellsbells•1h ago
I know Perl gets no love here, and for good reason sometimes, but I have a hard time believing that code full of syntactical characters like

  if .["found"] then
    . | .after += [$arg]
  elif $arg == "--" then
    . | .found = true
  else
    . | .before += [$arg]
  end
or

  for (i = $indicies) if { ~ $*($i) -- } {
      before = <= {
  ...
...is more readable and maintainable than:

  my ($before, $after) = split /\s*--\s*/, $input;
  my @list1 = split ' ', $before;
  ...

GPT-5

https://openai.com/gpt-5/
1010•rd•3h ago•1134 comments

Historical Tech Tree

https://www.historicaltechtree.com/
64•louisfd94•1h ago•18 comments

GPT-5: Key characteristics, pricing and system card

https://simonwillison.net/2025/Aug/7/gpt-5/
258•Philpax•2h ago•81 comments

Benchmark Framework Desktop Mainboard and 4-node cluster

https://github.com/geerlingguy/ollama-benchmark/issues/21
89•geerlingguy•2h ago•8 comments

GPT-5 for Developers

https://openai.com/index/introducing-gpt-5-for-developers
250•6thbit•3h ago•118 comments

Building Bluesky comments for my blog

https://natalie.sh/posts/bluesky-comments/
206•g0xA52A2A•4h ago•88 comments

Encryption made for police and military radios may be easily cracked

https://www.wired.com/story/encryption-made-for-police-and-military-radios-may-be-easily-cracked-researchers-find/
30•mikece•2h ago•16 comments

Show HN: Octofriend, a cute coding agent that can swap between GPT-5 and Claude

https://github.com/synthetic-lab/octofriend
37•reissbaker•2h ago•18 comments

Windows XP Professional

https://win32.run/
208•pentagrama•6h ago•128 comments

Infinite Pixels

https://meyerweb.com/eric/thoughts/2025/08/07/infinite-pixels/
201•OuterVale•7h ago•45 comments

DNA tests are uncovering the true prevalence of incest (2024)

https://www.theatlantic.com/health/archive/2024/03/dna-tests-incest/677791/
59•georgecmu•2h ago•34 comments

How to sell if your user is not the buyer

https://writings.founderlabs.io/p/how-to-sell-if-your-user-is-not-the
109•mooreds•5h ago•56 comments

Foundry (YC F24) is hiring staff-level product engineers

https://www.ycombinator.com/companies/foundry/jobs/jwdYx6v-founding-product-engineer
1•lakabimanil•3h ago

Lightweight LSAT

https://lightweightlsat.com/
35•gregsadetsky•2h ago•19 comments

OpenAI's new open-source model is basically Phi-5

https://www.seangoedecke.com/gpt-oss-is-phi-5/
13•emschwartz•1h ago•1 comments

Open music foundation models for full-song generation

https://map-yue.github.io/
21•selvan•3d ago•3 comments

Show HN: Browser AI agent platform designed for reliability

https://github.com/nottelabs/notte
26•ogandreakiro•3h ago•7 comments

Gemini CLI GitHub Actions

https://blog.google/technology/developers/introducing-gemini-cli-github-actions/
211•michael-sumner•11h ago•87 comments

How AI conquered the US economy: A visual FAQ

https://www.derekthompson.org/p/how-ai-conquered-the-us-economy-a
119•rbanffy•10h ago•118 comments

The Q Programming Language

https://git.urbach.dev/cli/q
5•ygritte•3d ago•0 comments

Laptop Support and Usability (LSU): July 2025 Report

https://github.com/FreeBSDFoundation/proj-laptop/blob/main/monthly-updates/2025-07.md
85•grahamjperrin•6h ago•45 comments

Monte Carlo Crash Course: Quasi-Monte Carlo

https://thenumb.at/QMC/
88•zote•3d ago•9 comments

A generic non-invasive neuromotor interface for human-computer interaction

https://www.nature.com/articles/s41586-025-09255-w
17•msephton•3d ago•2 comments

Italy's pizza detectives

https://www.bbc.com/travel/article/20250801-italys-undercover-pizza-detectives
34•pseudolus•4d ago•39 comments

Leonardo Chiariglione: “I closed MPEG on 2 June 2020”

https://leonardo.chiariglione.org/
191•eggspurt•10h ago•181 comments

Jepsen: Capela dda5892

https://jepsen.io/analyses/capela-dda5892
60•aphyr•5h ago•6 comments

Zero-day flaws in authentication, identity, authorization in HashiCorp Vault

https://cyata.ai/blog/cracking-the-vault-how-we-found-zero-day-flaws-in-authentication-identity-and-authorization-in-hashicorp-vault/
200•nihsy•13h ago•87 comments

The Sunlight Budget of Earth

https://www.asimov.press/p/sunlight-budget
36•mailyk•4h ago•12 comments

Arm desktop: emulation

https://marcin.juszkiewicz.com.pl/2025/07/22/arm-desktop-emulation/
75•PaulHoule•8h ago•34 comments

Preventing ZIP parser confusion attacks on Python package installers

https://blog.pypi.org/posts/2025-08-07-wheel-archive-confusion-attacks/
36•miketheman•4h ago•8 comments