the Bourne Shell is one of the two predominant Unix shells.
Modern variants of the Bourne Shell include
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.
#! /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 ) }
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:
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