Version 4 of Bourne Shell

Updated 2015-01-09 00:58:50 by pooryorick

the Bourne Shell is one of the two predominant Unix shells.

Reference

Wikipedia
The Traditional Bourne Shell Family , Sven Mascheck, 2001-10-07 - 2014-05-03
Shell Command Language , The Open Group Base Specifications Issue 7 , 2013
sh - shell, the standard command language interpreter , The Open Group Base Specifications Issue 6 , 2004

Implementations

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 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.

#! /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
    )
}

See Also

Playing Bourne shell