4 ms·
Writing a shell in C is in some ways easier than writing a shell in a higher language. We just ported fish from C/C++ to rust and the amount of semantically un
by ComputerGuru 2y ago
Writing a shell in C is in some ways easier than writing a shell in a higher language.
We just ported fish from C/C++ to rust and the amount of semantically unsafe operations a shell does (eg passing around file descriptors instead of a File object that can only have a single mutable reference unless you want to place it in a lock) and the onerous requirements of OS internals that require the use of only async-safe methods in signal handlers and post-fork/pre-exec (which is hard/impossible to do correctly if you’re using high-level wrappers) are quite something.
C is probably the ideal language for a basic shell, which should come as no surprise as OS and libc functionality to make that happen was co-developed.