From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17085 invoked from network); 9 Dec 1998 03:22:55 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 9 Dec 1998 03:22:55 -0000 Received: (from list@localhost) by math.gatech.edu (8.9.1/8.9.1) id WAA10178; Tue, 8 Dec 1998 22:21:38 -0500 (EST) Resent-Date: Tue, 8 Dec 1998 22:21:38 -0500 (EST) Message-ID: <19981209032532.54741@athenaeum.demon.co.uk> Date: Wed, 9 Dec 1998 03:25:32 +0000 From: Phil Pennock To: Zsh Development Workers Subject: Notes on bash(1) Mail-Followup-To: Zsh Development Workers Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.89.1 Organisation: Organisation? Here? No, over there ----> X-Disclaimer: Any views expressed in this message, where not explicitly attributed otherwise, are mine and mine alone. Such views do not necessarily coincide with those of any organisation or company with which I am or have been affiliated. X-Phase-of-Moon: The Moon is Waning Gibbous (67% of Full) Resent-Message-ID: <"HxBV1.0.zU2.2pURs"@math> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/4729 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu I recently needed to check something in bash(1) and noticed some interesting points in the manual. I'm throwing them this way for discussion/whatever. Bash is 2.01.1(1)-release. * bash has arrays. 'declare', 'local' & 'readonly' each accept '-a' to declare an array. Is it reasonable to add '-a' to 'typeset'? This would automatically duplicate the bash-ism. Further, would it be an idea to then deprecate 'set -A' which overloads parameter setting onto 'set'? * ${parameter/pattern/string} and ${parameter//pattern/string} pattern is expanded as per pathname expansion. Longest match of pattern against parameter is replaced with string. Once for / and for all instances with //. #pattern anchors to beginning, %pattern anchors to end. string may be null. Applied to an array, this works on each element. zsh has a some of this with the colon-modifier 's'. The anchors in particular are nice. They would make it easy to fully replicate basename(1) without forking. We can't currently (AFAIK) accurately duplicate $(basename file .ext) (think - filename: .ext.ex) % base=${var:t:s/%.ext//} * ${parameter:offset} and ${parameter:offset:length} provide substring and array extraction. Both length and offset are arithmetic expressions. length>=0. offset may be negative to measure from end. zsh notably has ${parameter[start,stop]} already. How desirable is this alternate syntax, given that zsh allows history modifiers in the same place? It doesn't look like there would be a conflict, provided zsh requires $[...] for variables there. Testing, bash allows: $ foo=abcde; t=2; echo ${foo:t} -- --> Phil Pennock ; GAT d- s+:+ a22 C++(++++) UL++++/I+++/S+++/H+ P++@ L+++ E-@ W(+) N>++ o !K w--- O>+ M V !PS PE Y+ PGP+ t-- 5++ X+ R !tv b++>+++ DI+ D+ G+ e+ h* r y?