Path should be a system call

https://news.ycombinator.com/rss Hits: 1
Summary

PATH should be a system call 2025/04/22 (... but... it's a variable... how do you even) Let us present the problem. This is Emacs starting up and loading some Lisp files. For which we first need to figure out where to find them. As it happens, they could be found at many possible locations. There is a list of these locations in the load-path variable; our method is to check whether it's present at each of them. (Also, maybe some of them come gzipped; let's check for those ones, too.) On my not especially overcomplicated Emacs install, the list has 59 elements. At first sight this sounds like such a niche problem. Not only is it about Emacs but it's also Windows; the latter is somewhat known of its less than excellent performance when it comes to small files. As it happens though, bash on Linux does the exact same thing. We have a list of directories on PATH, and, whenever we want to launch a program, we'll go and check each and one of them for the files we are looking for. We're fairly lucky though: the list is pretty short. ~ $ strace bash -c asdklfjasldfjaskldfasdljf (...) newfstatat(AT_FDCWD, ".", {st_mode=S_IFDIR|0755, st_size=4096, ...}, 0) = 0 newfstatat(AT_FDCWD, "/home/simon/bin/asdklfjasldfjaskldfasdljf", 0x7ffe5ff8d3c0, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/usr/local/bin/asdklfjasldfjaskldfasdljf", 0x7ffe5ff8d3c0, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/usr/bin/asdklfjasldfjaskldfasdljf", 0x7ffe5ff8d3c0, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/bin/asdklfjasldfjaskldfasdljf", 0x7ffe5ff8d3c0, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/usr/games/asdklfjasldfjaskldfasdljf", 0x7ffe5ff8d3c0, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/usr/local/games/asdklfjasldfjaskldfasdljf", 0x7ffe5ff8d3c0, 0) = -1 ENOENT (No such file or directory) ... except wait, now we're looking for ourselves? newfstatat(AT_FDCWD, ".", {st_mode=S_IFDIR|0755, st_siz...

First seen: 2025-04-25 01:53

Last seen: 2025-04-25 01:53