frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Open in hackernews

A shell colon does nothing. Use it anyway

https://refp.se/articles/your-shell-and-the-magic-colon
46•olexsmir•16h ago

Comments

kevincox•16h ago
I am not a huge fan of most of these, but a few do seem useful.

    : "${1:?missing argument, aborting!}"
I wouldn't use this because I would want to give $1 a name for the rest of the script, so I would assign. But it can be a nice way to give a clear error for missing required environment variables.

Many of the others (like truncating files) are probably more clearly written with dedicated commands, but may come in useful if you are going to extreme lengths to avoid dependencies outside of the shell.

refp•35m ago
Yo, author here.

You are very much correct and I 100% agree with you, I have updated the first example to include a snippet where a proper env-var is used to show of the automatic diagnostic.

Thanks for your feedback, much much appreciated!

jiveturkey•10h ago
the truncation is a poor example.

- it creates the file if it does not exist, not merely truncate. as a tutorial kind of blog post this incomplete description matters IMO.

- it would work the same without the colon (similar for default variable assignment examples). we generally strive not to have "extra" things, like useless use of cat.

- educationally it's useful to demonstrate that redirection, like parameter expansion, works before the command executes (the null command in this case), but the article doesn't explain that at all!

otherwise i <3 this article. some uses of colon i had never thought of or seen before. like file truncation, not sure i'd use them but it was cool to see them.

refp•27m ago
Hey jiveturkey, author here!

I agree with you, and for what it's worth the truncation snippet is very much tongue-in-cheek much like `( : >> output ) && echo "is writable"`.

I wasn't expecting anyone to actually use these in Prod, rather I aimed to show what can be done with a command designed to.. do nothing (crazy).

Happy you enjoyed the article, and thank you!

zaptheimpaler•58m ago
life is way too short to deal with this nightmare of a language and its 50000 footguns for anything longer than a 2 line script, especially in the age of LLMs. Just write a python/TS/any real language script instead. Bash is great for the command line, it should be limited to use there.
jghn•53m ago
It turns out that LLMs are really good at writing bash too. even perl! maybe we should rethink some of these lost bits because we no longer need to worry about the arcane parts.
AlecSchueler•16m ago
Define "really good?" I don't think I've ever had them produce a script that I didn't need to correct in some way. They can write it, that's true, but we still need to be able to read it.
jghn•5m ago
Fair. I'm comparing it to the output I see generated in more mainstream, day to day, languages. I'm not going to bother to get into an argument on if the frontier models can generate amazing code in general.

What I've found is I can get get the frontier models to generate bash scripts, perl one liners, etc that do exactly what I need at roughly the same quality as any other code it generates.

flexagoon•6m ago
Just use Fish
normie3000•32m ago
Prefer

``` if x then :; else something; fi ```

over

``` if ! x; then something; fi ```

Really? Colon is the appendix of the shell.

refp•17m ago
First of all, I must salute you on the joke; well put haha!

---

It is a (contrived) example of usage where a command is required and `:` can fill in the blanks. There are certainly scenarios where negating an expression becomes harder than doing the "dumb" way, and I for one has written code where `:` can be used as a placeholder meaning "fill this in later" or equivalent.

With that said, 100% agree with you that in actual "production" code - there is always a cleaner way.

croes•11m ago
https://www.gavi.org/vaccineswork/what-does-appendix-do-biol...

An ESP32 based plane radar for my desk

https://blog.ktz.me/esp32-plane-radar/
86•alexktz•3h ago•14 comments

A shell colon does nothing. Use it anyway

https://refp.se/articles/your-shell-and-the-magic-colon
50•olexsmir•16h ago•12 comments

JetZero

https://www.jetzero.aero
147•lisper•3h ago•101 comments

Show HN: I mapped every US golf course

https://golfcoursebrowser.com/
97•rickmf•4h ago•42 comments

The new rules of context engineering for Claude 5 generation models

https://claude.com/blog/the-new-rules-of-context-engineering-for-claude-5-generation-models
261•mellosouls•9h ago•167 comments

Inflect-Micro-v2: complete voice in 9.36M parameters

https://huggingface.co/owensong/Inflect-Micro-v2
78•nateb2022•5h ago•5 comments

Rethinking Legal Education in the AI Era

https://www.law.uchicago.edu/news/ai-strategy-statement
52•jjwiseman•2d ago•15 comments

Clinical failure rates over the decades: yikes

https://www.science.org/content/blog-post/clinical-failure-rates-over-decades-yikes
85•EA-3167•7h ago•48 comments

W4ME Station – a WASM-4 runtime for Java ME phones

https://github.com/mulfyx/w4me-station
11•sqshi•2h ago•1 comments

Systems and Delays

https://martin.janiczek.cz/2026/07/24/systems-and-delays.html
50•vinhnx•5h ago•12 comments

Alien World Chemistry Found Inside Meteorite That Struck New Jersey Home

https://www.seti.org/news/alien-world-chemistry-found-inside-meteorite/
34•spzx•4h ago•9 comments

Stinkpot: SQLite-backed shell history

https://tangled.org/oppi.li/stinkpot
14•nerdypepper•1d ago•1 comments

Running a 28.9M parameter LLM on an $8 microcontroller

https://github.com/slvDev/esp32-ai
141•boveyking•11h ago•29 comments

Cloudflare's new AI traffic options for customers

https://blog.cloudflare.com/content-independence-day-ai-options/
89•alphabetatango•7h ago•61 comments

LLM Usage in Debian: Three Proposals

https://www.debian.org/vote/2026/vote_002
126•zdw•10h ago•112 comments

GM Backs Sodium Ion Batteries for U.S. Grid Storage

https://spectrum.ieee.org/sodium-ion-battery-peak-energy
164•rbanffy•8h ago•66 comments

Open-weight AI is having its Kubernetes moment

https://tobi.knaup.me/2026-07-25-open-weight-ai-is-having-its-kubernetes-moment/
360•tknaup•15h ago•283 comments

Agatha Christie's Disappearance: Amnesia, Suicide, or Despair?

https://www.historicmysteries.com/unexplained-mysteries/agatha-christie-disappearance/23136/
17•thunderbong•3d ago•6 comments

SIMD for Collision

https://box2d.org/posts/2026/07/simd-for-collision/
82•birdculture•3d ago•26 comments

Humans haven't stopped evolving

https://www.harvardmagazine.com/research/harvard-human-evolution-genes-selective-pressure
51•ilamont•3h ago•49 comments

Zero roadkill as Amazon canopy bridges secure 15,000 crossings

https://news.mongabay.com/2026/07/zero-roadkill-as-amazon-canopy-bridges-secure-15000-crossings/
338•hn_acker•3d ago•98 comments

Librrd Playground

https://systemf.epfl.ch/etc/librrd/
3•E-Reverance•4d ago•0 comments

Show HN: I made some transistor animations

https://brandonli.net/semisim/animations
155•stunningllama•1d ago•19 comments

Producing ammonia and fertiliser using wind power in Morris, Minnesota

https://ammoniaenergy.org/articles/flexible-renewable-ammonia-demonstrator-now-operational-in-min...
115•gritzko•10h ago•80 comments

Show HN: Brolly, a plain-text weather forecast site

https://brolly.sh/forecast/RWFP2qW8
167•jsax•12h ago•50 comments

Retry Storm Lab

https://github.com/telemetry-sh/retry-storm-lab
5•flurly•3d ago•0 comments

Turn And Face The Strange

https://fly.io/blog/kurt-scott-money-sprites/
186•subarctic•9h ago•124 comments

Memory Safety Absolutists

https://itsallaboutthebit.com/memory-safety-absolutists/
81•drogus•12h ago•112 comments

Did They Ghost You?

https://didtheyghostyou.com/
359•mooreds•10h ago•162 comments

Android May Soon Restrict On-Device ADB

https://kitsumed.github.io/blog/posts/android-may-soon-restrict-on-device-adb/
902•shscs911•23h ago•445 comments