I'm interested in the Bourne Shell

I recently learned more about Linux than I ever knew beforehand by learning bash commands. It filled in gaps in my experience and opened my perspective and I could see more things to do. Before my efforts consisted of googling and getting someone else's commands that they used. So I got to thinking if I did the same with FreeBSD, in that case learning the Bourne shell commands, my view would then light on something new.
If, in addition to individual commands (=programs), you'd like some more consize useful information about sh(1) (i.e. the POSIX like shell in FreeBSD) and other useful CLI things like quoting and regular expression, I recommend having a look at The Grymoire - home for UNIX wizards
 
It is a challenge to find introduction for the USER to the UNIX environment. You can find many books and Youtube vidoes on how to install FreeBSD , including the FreeBSD Handbook. There is Kirk's book about the Design of the BSD operating system , but finding beginner texts in how to use UNIX is a challenge.
I have known two books that does the job :

#1 The UNIX Programming environment ( Kernighan / Pike ) 1984.
#2 Unix System V Release 4 An Introduction ( Rosen, Rosinski,Farber,Host ) 1994.

these books are not about installation , nor about system programming , but about using the UNIX Shells .
They are the UNIX foundation and Unix shell programming training courses we ran before the internet ruined teacher led trainings.
so if you have challenges with using the Command-line interface , doing all the exercises in these books will set you free.
 
I struggled with this for a while. Here is how I figured all of this out for my situation.

First off, I went searching around for advice. Bad idea. These are complex topics, no one size fits all.

Then I went looking for a way to justify the recommendations I was getting. Very difficult to figure out. Quite a puzzle. But I came up with a couple of ideas that address this issue, and others, and it is logical and precise.

I was using FreeBSD and that is what I wanted to work with. So I looked around. All the system supplied scripts are in bourne shell (sh).

Well, I had my first answer. If I was going to get good at FreeBSD as quick as possible I would need to learn sh so I would only script in sh.

Then I asked "why?". This was important to me. The only way to know is to figure it out. Why would FreeBSD only use sh for scripts? I will never know the answer to that question historically, but sh is at least good enough that it hasn't been changed out. So what are the advantages?

Well, sh runs pretty fast. So no performance reason to switch.
Sh is pretty limited. Well, I like that, faster to learn. But how is that not a reason to push it aside? I believe it is because sh does what it does and if sh doesn't do it you're supposed to offload that to another command like wc, awk, ls, df, host, dig, curl and thousands of other commands. Sh is the glue. It isn't supposed to do much because other programs will always do it faster and better.
So that was that.

Then csh and tcsh were on the terminal. My initial thought was make sh the prompt shell. I would only learn faster right? Well, sh isn't great as a terminal shell. For example, I really liked tcsh for the history. My biggest problem was I would test stuff on the command line and it wouldn't work in the shell. Well, I eventually figured out sh -c "<your command" was how you do that for individual commands. And if you want to try something with redirecting you can just use chsh "change shell" and switch to sh until you're unstuck.

So in the end I stayed with the default setup and I'm pretty happy.

PS I remember the perl debacle from years ago. I wrote some great admin stuff, very easy to do because I already knew perl. Just two years down the road I could barely read those scripts. This has never happened to me with Bourne. If I see a program I don't recognize I just do "man <program>" and I'm off and running again. If I find something I don't know how to do I go "man sh". If it isn't there I look for a program that does it. It took me about a month to really get the hang of it without this info but it would've been days if I knew what I just wrote here.
 
Steven Bourne's shell was the first shell , and the other shells are extensions to the Bourne shell.
A script that adheres to the sh limitations is runnable in the other shells as well.

Much Later some one made the Bourne Again SHell , whether this guy was a born-again Pentecostal , I have no idea. but it seems probable.
 
Back
Top