frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Test your square brackets

https://fluca1978.github.io/2025/12/10/testAndSquareBrackets.html
28•speckx•6d ago

Comments

theandrewbailey•1h ago
Now do [ ... ] and [[ ... ]]

I'm still not sure when to use one or the other. I use double brackets by default until something doesn't work.

stabbles•1h ago
Double brackets are less portable. For example musl linux does not come with bash by default, and your script fails.

When unsure, use shellcheck.

a3w•1h ago
[[ is built in, so "test[" as an /usr/bin artifact never exists? (What to call that proposed program, test2, or test[ ?)
duskdozer•59m ago
You mean shellcheck will detect when single brackets won't be enough? I've also just defaulted to double because I never really looked into it
PhilipRoman•1h ago
[[...]] is non-portable and has an extremely quirky corner case with variable expansion in arithmetic contexts, what's not to love?
ndsipa_pomu•7m ago
I'm intrigued - any info on that?

I personally use ((...)) for arithmetic tests and [[...]] for all other tests as I just target new versions of BASH and don't care much about POSIX compatibility.

nickjj•30m ago
[[ ... ]] supports regex comparisons and lets you combine multiple conditions in a single bracket group using && and || instead of remembering to use -a / -o.

I usually default to [ ... ] unless I need features that double brackets provide.

ndsipa_pomu•6m ago
Use ((...)) for arithmetic tests and [[...]] for other tests. [...] is for POSIX compatibility and not as useful as [[...]] though I don't remember the specifics.
jonhohle•1m ago
[[…]] is a bash (probably other shells, too) built in. […] could be a built in, or could be a symlink to /bin/test.
reactordev•1h ago
The ultimately sad part was the professor in a Sun OS machine.

In a corner with no where to go, giving demerits because his bash was older than he realized.

Reminds me of my college professor that claimed you don’t have to close HTML tags (some you absolutely do) and I proved that you do. Not all of them, but most of them. (Netscape Navigator Days)

jonhohle•4m ago
It doesn’t have anything to do with bash (though modern bash may use a built in for `[`). He don’t have the `[` program (usually linked to `test`).
Wowfunhappy•1h ago
> When I was a young, green, university student, I was forced to use test(1) as the only true way to do testing in shell scripting. […] Yeah, I was also forced to not use semicolons as they were evil (according to my professor, any comment unneeded!).

The author’s professor clearly went gone overboard, but doesn’t this entire anecdote demonstrate the value of teaching it this way? Having green students call the `test` binary provides more insight into how UNIX operates, and gets them into that mindset.

ogogmad•5m ago
Hmm. What if we replaced the whole of bash with the contents of /bin?
stabbles•1h ago
Nowadays [ is a builtin. The subprocess for a simple branch would be excessive overhead.
MontyCarloHall•44m ago
It is indeed a builtin, but `/bin/[` still exists for compatibility reasons!

   $ which [
   /bin/[
   $ type [
   [ is a shell builtin
The same is true for the `test` command:

   $ which test
   /bin/test
   $ type test
   test is a shell builtin
xg15•13m ago
So if you really want to troll someone, you can put them in quotes.

  if "[" "$foo" "==" "bar" "]"; then ...
ndsipa_pomu•4m ago
Here's Greg's Wiki about the difference between [, [[ and test

https://mywiki.wooledge.org/BashFAQ/031

The 500k-ton typo: Why data center copper math doesn't add up

https://investinglive.com/news/the-500000-ton-typo-why-data-center-copper-math-doesnt-add-up-2026...
32•thebeardisred•1h ago•30 comments

A letter to those who fired tech writers because of AI

https://passo.uno/letter-those-who-fired-tech-writers-ai/
208•theletterf•6h ago•130 comments

The URL shortener that makes your links look as suspicious as possible

https://creepylink.com/
513•dreadsword•10h ago•104 comments

Claude Cowork exfiltrates files

https://www.promptarmor.com/resources/claude-cowork-exfiltrates-files
732•takira•17h ago•326 comments

Raspberry Pi's New AI Hat Adds 8GB of RAM for Local LLMs

https://www.jeffgeerling.com/blog/2026/raspberry-pi-ai-hat-2/
155•ingve•5h ago•111 comments

The 3D Software Rendering Technology of 1998's Thief: The Dark Project (2019)

https://nothings.org/gamedev/thief_rendering.html
26•suioir•3h ago•7 comments

Test your square brackets

https://fluca1978.github.io/2025/12/10/testAndSquareBrackets.html
28•speckx•6d ago•17 comments

Z80 Mem­ber­ship Card

https://sunrise-ev.com/z80.htm
50•exvi•3d ago•14 comments

Impeccable Style

https://impeccable.style
19•noemit•3d ago•9 comments

Jiga (YC W21) Is Hiring Full Stack Engineers

https://jiga.io/about-us
1•grmmph•2h ago

French Court Orders Popular VPNs to Block More Pirate Sites, Despite Opposition

https://torrentfreak.com/french-court-orders-popular-vpns-to-block-more-pirate-sites-despite-oppo...
17•iamnothere•48m ago•4 comments

Ask HN: How are you doing RAG locally?

227•tmaly•23h ago•97 comments

Ask HN: Share your personal website

685•susam•20h ago•1897 comments

San Remo Pasta Measurer

https://www.toxel.com/tech/2025/09/17/san-remo-pasta-measurer/
25•surprisetalk•5d ago•14 comments

Photos Capture the Breathtaking Scale of China's Wind and Solar Buildout

https://e360.yale.edu/digest/china-renewable-photo-essay
209•mrtksn•4h ago•137 comments

Scaling long-running autonomous coding

https://cursor.com/blog/scaling-agents
229•samwillis•15h ago•138 comments

Ask HN: What did you find out or explore today?

135•blahaj•20h ago•220 comments

Show HN: MailPilot – Freedom to go anywhere while your agents work

13•keepamovin•6h ago•14 comments

Handy – Free open source speech-to-text app

https://github.com/cjpais/Handy
140•tin7in•8h ago•77 comments

New Safari developer tools provide insight into CSS Grid Lanes

https://webkit.org/blog/17746/new-safari-developer-tools-provide-insight-into-css-grid-lanes/
88•feross•13h ago•50 comments

Bubblewrap: A nimble way to prevent agents from accessing your .env files

https://patrickmccanna.net/a-better-way-to-limit-claude-code-and-other-coding-agents-access-to-se...
125•0o_MrPatrick_o0•12h ago•97 comments

Python: Tprof, a Targeting Profiler

https://adamj.eu/tech/2026/01/14/python-introducing-tprof/
22•jonatron•5h ago•0 comments

The State of OpenSSL for pyca/cryptography

https://cryptography.io/en/latest/statements/state-of-openssl/
164•SGran•15h ago•36 comments

Crafting Interpreters

https://craftinginterpreters.com/
152•tosh•15h ago•30 comments

Furiosa: 3.5x efficiency over H100s

https://furiosa.ai/blog/introducing-rngd-server-efficient-ai-inference-at-data-center-scale
189•written-beyond•13h ago•128 comments

Show HN: Sparrow-1 – Audio-native model for human-level turn-taking without ASR

https://www.tavus.io/post/sparrow-1-human-level-conversational-timing-in-real-time-voice
85•code_brian•20h ago•19 comments

Bare metal programming with RISC-V guide (2023)

https://popovicu.com/posts/bare-metal-programming-risc-v/
43•todsacerdoti•5d ago•8 comments

SparkFun Officially Dropping AdaFruit due to CoC Violation

https://www.sparkfun.com/official-response
479•yaleman•23h ago•479 comments

Find a pub that needs you

https://www.ismypubfucked.com/
334•thinkingemote•22h ago•300 comments

Show HN: WebTiles – create a tiny 250x250 website with neighbors around you

https://webtiles.kicya.net/
204•dimden•5d ago•32 comments