Bourne shell programming questions
Steve Rudek
stever at tree.UUCP
Sat Oct 15 04:23:03 AEST 1988
Although I've got access to a number of books on shell programming, I've
yet to find any rigorous, comprehensive text on shell programming; that
would be okay if I could even find an excellent *combination* of texts.
_The UNIX Programming Environment_, by Kernighan and Pike, is a very good
book but it is not *nearly* comprehensive enough (for example, it only
mentions the "eval" command in a "Hint" and it doesn't discuss named
procedures at all!).
I think the lack of decent sh documentation is a shame. I've found that
most UNIX "wizards" are actually only "C" wizards and have basically missed
the boat with regard to what (in my opinion) UNIX is all about! Shell
script is an immensely powerful 4th GL but most folks treat it like it is
just a run-of-the-mill JCL and only use it for short utility programs.
Anyway, enough of that; I actually wanted to ask a couple of questions!
(1) I'm making extensive use of *very long* environment strings (using expr to
build and strip them of "field" information). I'm also using lots of
named procedures and, in some occasions, calling them *recursively* (neat
trick, that!). I'd like to expand the use of memory variables since it
reduces the need for disk access. How much variable space do I have to
play with? Is this defined or at all standardized across machines?
(2) As I see it, the secret to writing interactive programs in shell script
is to reduce disk access time to a minimum. There is a "hash" command
defined for shell which is scantily described in man. Man indicates that
it can be used to "remember" the exact path to given commands and, thus,
reduce the overhead of calling external programs? As usual, the sh
documentation gives no example. Well, perhaps for this command no
documentation should be needed -- but I've "time"d scripts with and
without use of this command and found no execution time difference.
Comments?
P.S. I've got access to a korn shell. How transportable are bourne scripts
and is korn sufficiently more advanced (as a programming language) to make
it worth my while to switch?
More information about the Comp.unix.wizards
mailing list