The history and use of /etc./glob in early Unixes
9 comments
·January 13, 2025yjftsjthsd-h
> PS: I don't know why expanding shell wildcards used a separate program in V6 and earlier, but part of it may have been to keep the shell smaller and more minimal so that it required less memory.
See, I thought it was a nice separation of concerns and wondered why we lost such a nice approach, until I read:
> How escaping wildcards works in the V5 and V6 shell is that all characters in commands and arguments are restricted to being seven-bit ASCII. The shell and /etc/glob both use the 8th bit to mark quoted characters, which means that such quoted characters don't match their unquoted versions and won't be seen as wildcards by either the shell
at which point I suddenly became a fan of ditching it. I do wonder if there's not some better way to factor that functionality out...
p_l
Important thing to remember is that even after the move to PDP-11, early Unix systems had to deal with 32kB as entire space available to userland program, both code and data (including stack)
Joker_vD
Why would I want to factor out some syntactic functionality of one specific (and not very well thought out) shell to reuse, again?
But if you really insist, you can write your own glob(1) that would invoke glob(3) for you, sure. There is also wordexp(3) although I believe its implementations had security problems for quite some time?
eru
> at which point I suddenly became a fan of ditching it. I do wonder if there's not some better way to factor that functionality out...
Just use backslash escaping like we do practically everywhere else in the Unix world?
hnlmorg
The way Murex works is each parameter is first compiled into an AST, and then globing only works against the unquoted tokens.
Globbing is also a separate built in, which allows for other types of wildcard matches like regex too. Eg https://murex.rocks/tour.html#filesystem-wildcards-globbing
So you have have the best of both worlds: inline globbing for convenience and also wildcard matching as a function too.
null
Sweet.
I use xterm.js a lot and have a "shell backbone" that I use to make shell based access to APIs, S3 and other things "cloud." This is essentially how I implement globbing as well. The convenience is that you can run glob by itself to get an idea of exactly what kind of automated nightmare you are about to kick off.
Anyways.. mine currently has V3 behavior. My shell command exec routine could actually benefit from that hack. What's old is new again?