the '''http://en.wikipedia.org/wiki/Bourne_shell%|%Bourne Shell''' is one of the two predominant [Unix shells]. ** Reference ** [http://en.wikipedia.org/wiki/Bourne_shell%|%Wikipedia]: [http://www.in-ulm.de/~mascheck/bourne/%|%The Traditional Bourne Shell Family], Sven Mascheck, 2001-10-07 - 2014-05-03: [http://pubs.opengroup.org/onlinepubs/9699919799/idx/shell.html%|%Shell Command Language], [http://pubs.opengroup.org/onlinepubs/9699919799/%|%The Open Group Base Specifications Issue 7], 2013: [http://pubs.opengroup.org/onlinepubs/009695399/utilities/sh.html%|%sh - shell, the standard command language interpreter], [http://pubs.opengroup.org/onlinepubs/009695399/%|%The Open Group Base Specifications Issue 6], 2004: ** Implementations ** [http://heirloom.sourceforge.net/sh.html%|%The Heirloom Bourne Shell]: ** Variants ** Modern variants of the Bourne Shell include ash: [bash]: [ksh], by [David Korn]: a popular Bourne-compatible shell which is also available on [Microsoft Windows%|%Windows]. zsh: ** Load or Generate a Tcl [List] ** Here are some shell functions to generate a Tcl list from a sequence of values, and to load a Tcl list into an array. They're handy, among other things, for storing and loading structured data. ======none #! /bin/env bash : ${TCLSH:=tclsh} #generate a Tcl list from a sequence of arguments #example: mylist=$(tcllist one two three '{' ) tcllist () { local libpath local res res=$("$TCLSH" - "$@" <<-'EOF' puts [lrange $argv 1 end] EOF ) printf %s "$res" } #load a Tcl list into an array #example: tcllist_arr myarray '{one two {three four} five}' tcllist_arr () { assert declare "$1" eval $1'=()' while read -d $'\0'; do eval $1'[${#'$1'[*]}]="$REPLY"' done < <( "$TCLSH" - "${@:2:$#}" <<-'EOF' proc main {arg0 argv} { set list [lindex $argv 1] foreach item $list { puts -nonewline $item\0 } } main $argv0 $argv EOF ) } ====== ** Why Bourne Shell Is not Fit for Programming ** It is well-known that [csh] is not fit for programming. Bourne shells also do not rise to the occasion. One big issue is their scoping rules. In the following example, `$i` in the second function interferes with `$i` in the first function: ======none f1 () { local i for ((i=0 ;i<10 ;i++)); do echo $i f2 done } f2 () { for ((i=0 ;i<5 ;i++)); do #do something useful : done } f1 ====== ---- [PYK] 2015-08-04: In my opinion, one of the biggest reasons not to write programs in the Bourne shell language is that subshells swallow errors. In the following example, `hello` is not expected to print because the interpreter should exit when the unknown variable, $k is referenced, and indeed it doesn't: ====== /bin/env sh set -u echo $x echo hello ====== In sh scripting, however, it's extremely common to run commands in a subshell and collect their output. In the following example, even `hello` does print even though the shell is configured as before: ====== /bin/env sh set -u echo $(echo $x) echo hello ====== Programming in a dynamic language is already adventurous enough. At least choose a sane dynamic language like Tcl. Beware the ''This is going to be a smallish script so I'll just write it in sh'' trap. ** See Also ** [Playing Bourne shell]: <> Unix Shells