There are several Bourne Shell variants available on open systems to perform rudimentary shell scripting.  The traditional Bourne Shell ("sh") has been fading in the sunset though it is lightweight for use by the OS.  I have found that for the user environment, Bash (Bourne Again Shell) is the logical choice that is packaged on all open system platforms and consistently named (/usr/bin/bash).  From a scripting standpoint, though I prefer Korn, Bash is universal enough and has some notion of the advanced Korn features, though not as robust (e.g. smart variable substitution options/functionality).  

 

Another popular Bourne based shell is the Korn Shell.  Originally developed by David Korn, until about 2000, the source code was proprietary code licensed by AT&T.  In about 2000, the code was released to open source.  There are two significant versions released - KSH 1988 and KSH 1993.  On Linux, an open source version pdksh is roughly the 1993 version.  On proprietary UNIX systems, both the traditional Korn 1988 and 1993 are supplied, though not consistently named across OS variants as an executable.

So, what is the purpose of the Shell?  It was originally developed as a way for an end user to start the execution of a program in the operating system.  It was also a simple way to provide a simplistic code base to perform a stacked execution of commands to produce a desired end result.  If you only need simple logic branching and don't require computational math a shell script is suitable.  A common mistake that scripters often do is parsing multiple lines out of an input source that have to be considered as one (e.g. parsing through an LDIF).  Another tool should be used such as Perl or Python for advanced scripting.

Arrays are basic.  There is only one type available - the indexed array.  To replicate a key/value oriented array, you have to use two arrays that are loaded simultaneously.  In parsing the array, you have to use script logic to parse the "key" array and use that index on the "value" array.  There is no ability to perform fuzzy matches.  You have to condition on the whole string for a match.

One last point to make is over environmental variable scope.  Variables are all in the "global scope" unlike other scripting languages.  That means that the contents of a named variable is universally available throughout the script using the same name.  Other languages handle named variables locally within the scope of a function unless it is declared to be global.  Where one function is subordinate to another function, it's variables are inherited from its parent.

Tuesday 18th of February 2020 -  Copyright 2016 Allan Wolfe