Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> every command you run in a script is basically a fork

Not for built-in commands.

> Yeah “fork is slow” is the sort of microbenchmark that is mostly irrelevant for shell scripts

Maybe if you're on a Linux kernel, but not everywhere else.



Where are you running bash where forks are expensive? Like sure Windows exists but bash on WSL is running a Linux kernel.


Not quite. WSL2 uses a Linux kernel. WSL1 uses a Windows kernel and fork is much slower there. Also there's userspace variants like MSYS2, Cygwin, etc.


When I am using busybox sh/bash, I am very, very careful not to fork unless I must.

For mass processing, I will use xargs to minimize the number of processes created.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

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

Search: