/bin/shCasi nunca es un shell Bourne en ningún sistema hoy en día (incluso Solaris, que fue uno de los últimos sistemas importantes en incluirlo, ahora ha cambiado a POSIX sh por su / bin / sh en Solaris 11). /bin/shfue la concha de Thompson a principios de los 70 El shell Bourne lo reemplazó en Unix V7 en 1979.
/bin/sh ha sido el shell Bourne durante muchos años a partir de entonces (o el shell Almquist, una reimplementación gratuita en BSD).
Hoy en día, /bin/shes más comúnmente un intérprete u otro para el shlenguaje POSIX que se basa en un subconjunto del lenguaje de ksh88 (y un superconjunto del lenguaje shell Bourne con algunas incompatibilidades).
El shell Bourne o la especificación del lenguaje POSIX sh no admiten matrices. O, más bien que sólo tienen una matriz: los parámetros posicionales ( $1, $2, $@, por lo que una matriz por la función, así).
ksh88 tenía matrices con las que configuró set -A, pero eso no se especificó en POSIX sh ya que la sintaxis es incómoda y no muy utilizable.
Otros conchas con variables de matriz / listas incluyen: csh/ tcsh, rc, es, bash(que en su mayoría copiado la sintaxis ksh la forma ksh93), yash, zsh, fishcada uno con una sintaxis diferente ( rcla cáscara de la vez sea-sucesor de Unix, fishy zshsiendo el más consistente unos) ...
En estándar sh(también funciona en versiones modernas del shell Bourne):
set '1st element' 2 3 # setting the array
set -- "$@" more # adding elements to the end of the array
shift 2 # removing elements (here 2) from the beginning of the array
printf '<%s>\n' "$@" # passing all the elements of the $@ array
# as arguments to a command
for i do # looping over the elements of the $@ array ($1, $2...)
printf 'Looping over "%s"\n' "$i"
done
printf '%s\n' "$1" # accessing individual element of the array.
# up to the 9th only with the Bourne shell though
# (only the Bourne shell), and note that you need
# the braces (as in "${10}") past the 9th in other
# shells.
printf '%s\n' "$# elements in the array"
printf '%s\n' "$*" # join the elements of the array with the
# first character (byte in some implementations)
# of $IFS (not in the Bourne shell where it's on
# space instead regardless of the value of $IFS)
(tenga en cuenta que en el shell Bourne y ksh88, $IFSdebe contener el carácter de espacio para "$@"que funcione correctamente (un error), y en el shell Bourne, no puede acceder a los elementos anteriores $9( ${10}no funcionará, aún puede hacer shift 1; echo "$9"o recorrer) ellos)).