From owner-freebsd-stable Sat Sep 16 10:54:44 2000 Delivered-To: freebsd-stable@freebsd.org Received: from androcles.com (androcles.com [204.57.240.10]) by hub.freebsd.org (Postfix) with ESMTP id 5450337B423 for ; Sat, 16 Sep 2000 10:54:40 -0700 (PDT) Received: (from dhh@localhost) by androcles.com (8.9.3/8.9.3) id KAA98962; Sat, 16 Sep 2000 10:54:28 -0700 (PDT) Message-ID: X-Mailer: XFMail 1.4.0 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit MIME-Version: 1.0 In-Reply-To: <20000915211957.A1285@nc.rr.com> Date: Sat, 16 Sep 2000 10:54:27 -0700 (PDT) From: "Duane H. Hesser" To: Randall Hopper Subject: Re: "set -A" Bourne script - a nogo on FreeBSD Cc: freebsd-stable@FreeBSD.ORG, Gregory Bond Sender: owner-freebsd-stable@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG "set -A' is ksh's method for declaring an array. The "real" Bourne shell does not support arrays (hence no way to declare them). Frequently, /bin/sh is not a "real" Bourne shell, rather some other shell (bash, zsh, ksh) emulating the Bourne shell (e.g. /bin/sh is usually "bash" on linux). Bash and zsh, when called as 'sh', try to dumb themselves down to look like the Bourne shell, but the "dumbing down" is imperfect, and neither of them disables support for arrays. Bash (even when running as 'sh') will declare arrays using 'typset -a' (or declare -a); zsh declares arrays with 'typeset -A'. Ksh declares arrays with 'set -A', and associative arrays with 'typeset -A'. Some systems install ksh88 as /bin/sh, but so far as I know, it does not behave differently (i.e. attempt to emulate 'sh'). Usually the manual page will alert you to this. All of the above shells will allow declaring an array implicitly, in the 'csh' style, with something like wombat=( 1 2 3 4 5 ) All of the shells except 'zsh' use array indices starting with '0'; zsh array indices start with '1' (unless it's running in 'ksh' emulation mode). You may be able to identify the shell using 'set | grep VERSION'; bash sets BASH_VERSION, zsh sets ZSH_VERSION, and the pd emulation of ksh sets KSH_VERSION. Otherwise, if it has arrays, it is probably ksh88 or ksh93. ksh93 can be identified by 'echo ${.sh.version}'. I have no idea how to ID ksh88 (it's been too long), but if the shell supports arrays, and isn't one of the above, it's probably ksh88. Ksh93 has only recently gone "open-source", so the likelihood is that the IRIX shell is ksh88 (just a guess). On 16-Sep-00 Randall Hopper wrote: > Gregory Bond: > |> Seems FreeBSD's Bourne shell's "set" command doesn't support -A. > | > |AFAICT "set -A" is a ksh-ism, not a bourne-ism. On my Solaris systems, ksh > |has "set -A", but neither bash nor sh do. Install one of the ksh verisions > |from the ports. > > Ok, maybe it isn't a universal Bourne-ism then. > > Reason I asked is my /bin/sh on IRIX at work has set -A. > > -- > Randall Hopper > aa8vb@nc.rr.com > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-stable" in the body of the message > -------------- Duane H. Hesser dhh@androcles.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-stable" in the body of the message