henry_flower: A melancholy wolf (Default)
henry_flower ([personal profile] henry_flower) wrote2017-07-10 02:17 am

The origin of the name 'glob'

TIL, glob is short for "global" (expression) & once upon a time there was a separate /bin/glob command!

Date: Fri, 07 Jul 2017 20:04:22 -0700
From: Steve Johnson <scj-NwtWUD4K+P9BDgjK7y7TUQ@public.gmane.org>
Newsgroups: gmane.org.unix-heritage.general
Subject: Re: origin of the name 'glob'
X-Mailer: Atmail
Message-ID: <90d3e82762409a1fcb835ce0e0c3cf9a5602bfe7@webmail.yaccman.com>

Doug would probably be a better source, but, as you know, grep stands
for global regular expression print.  This is a literal translation
into words of a common idiom in vi (and ed before that):  g/xxx/p
which prints all the lines that match xxx.  The g means that it finds
all lines, rather than just searching for one.

Since glob tends to match more than one thing, but not in the usual
way, I suspect that it is a shortening of "global regular expression
print"  (with no print, and not, strictly speaking, the usual regular
expression syntax either)...

As to why regular expressions are called "regular" expressions, that
happened long before Unix...

Date: Sun, 09 Jul 2017 08:26:56 -0400
From: Doug McIlroy <doug-bJGkzYaaMJvEkZP4S/TgZg@public.gmane.org>
Newsgroups: gmane.org.unix-heritage.general
Subject: Re: origin of the name 'glob'
User-Agent: Heirloom mailx 12.5 7/5/10
Message-ID: <201707091226.v69CQuvp031800@coolidge.cs.Dartmouth.EDU>

Glob was an an accident. When Ken and Dennis wanted to put wildcards
(an anachronistic word--it wasn't used in the Unix lab at the time)
into the shell, there wasn't room, so they came up with the clever hack
of calling another process to do the work.

I have always understood that glob meant global because commands like
        rm *
would be applied to every file in a directory. A relationship to ed's
g command was clear, but not primary in my mind.

One curious fact is that from day one the word hase been pronounced glob,
not globe. (By contrast, creat has been variously pronounced cree-at
and create.)  It is also interesting to speculate on whether there would
be a glob library routine in Linux had glob only been an identifier in
sh.c rather than an entry in /bin.

I believe the simple * was borrowed from somewhere else. If the g command
had been the driving model, glob would probably have had ? and ?*, not
? and *. (It couldn't use ed's . because . was ubiquitous in file names.)

My etymology is somewhat different from Steve's. But I never asked the
originator(s). Steve, did you?