Tuesday, February 7, 2023

wordexp() Shells Out

Steve Klabnik:

you: “c is nice because there’s no hidden costs, you see every malloc and free, and know that the standard library doesn’t do shenanigans behind your back”

Steve Troughton-Smith:

libc does what 😟

Apparently I forgot to link to this back when the story broke in 2015 and 2016. For many years, Apple implemented the wordexp() function by starting a separate process for a Perl interpreter. Later, this was changed to use /usr/lib/system/wordexp-helper, which may be based on Bash, and so perhaps the code can only be called that way because of the GPL.


2 Comments RSS · Twitter · Mastodon

That is so UNIX. Back in the 1980s, we wondered how the getwd() - get working directory - routine could fail as it often did. Surely, it couldn't be that hard to get the current working directory. It turned out that the wd was stored as an inode number, and getwd fired up a process to invoke the pwd command and grabbed the output through a pipe. The pwd command could figure out how to trace the inodes up to the root and build the necessary string.

The more things change ...

That was HP-UX, hockey pux, for you UNIX fans.

Leave a Comment