Matching words against a list in the Bourne ShellOne of the interesting challenges in writing shell scripts is figuring out how to do as much as is practical with shell builtins and primitives. Since Bourne shell builtins are such a limited and constrained environment, the results can be somewhat perverse and peculiar and thus neat and amusing. (If you can find an efficient way of doing things, using builtins is much faster than having to resort to external programs, especially when the system is loaded.) My challenge today was checking whether a word was in a list of words (words don't have spaces), in a Bourne shell dialect that would work as far back as Solaris 2.5. What I came up with is:
(Where I sometimes feel I have an advantage in this sort of perversity, because
I started out writing shell scripts in a version of the Bourne shell
that was so old that it didn't even have (To this day I have a tendency to use (3 comments.)
|
These are my WanderingThoughts GettingAround This is part of CSpace, and is written by ChrisSiebenmann. * * * Atom feeds are available; see the bottom of most pages. Categories: links, linux, programming, python, snark, solaris, spam, sysadmin, tech, unix, web |