From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1734 invoked from network); 4 Dec 2000 11:57:39 -0000 Received: from sunsite.dk (HELO sunsite.auc.dk) (130.225.51.30) by ns1.primenet.com.au with SMTP; 4 Dec 2000 11:57:39 -0000 Received: (qmail 4321 invoked by alias); 4 Dec 2000 11:57:33 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 13220 Received: (qmail 4314 invoked from network); 4 Dec 2000 11:57:32 -0000 Date: Mon, 04 Dec 2000 11:57:04 +0000 From: Peter Stephenson Subject: Re: Evaluation of $# - bug? In-reply-to: "Your message of Mon, 04 Dec 2000 12:33:49 +0100." <200012041133.MAA05780@beta.informatik.hu-berlin.de> To: zsh-workers@sunsite.auc.dk (Zsh hackers list) Message-id: <0G51000DAL739B@la-la.cambridgesiliconradio.com> Content-transfer-encoding: 7BIT > Always remember that there is a parameter named `-' (the option > string), so `$#-' gives the length of the value of that parameter and > `$#-1' gives that with a `1' stuck to the end. > > Use `${#}-1'. This probably deserves a special note. Unless anybody really objects to clarity in the documentation. Index: Doc/Zsh/params.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/params.yo,v retrieving revision 1.5 diff -u -r1.5 params.yo --- Doc/Zsh/params.yo 2000/08/29 06:35:40 1.5 +++ Doc/Zsh/params.yo 2000/12/04 11:55:35 @@ -240,7 +240,11 @@ ) vindex(#) item(tt(#) )( -The number of positional parameters in decimal. +The number of positional parameters in decimal. Note that some confusion +may occur with the syntax tt($#)var(param) which substitutes the length of +var(param). Use tt(${#}) to resolve ambiguities. In particular, the +sequence `tt($#-)var(...)' in an arithmetic expression is interpreted as +the length of the parameter tt(-), q.v. ) vindex(ARGC) item(tt(ARGC) )( -- Peter Stephenson Software Engineer Cambridge Silicon Radio, Unit 300, Science Park, Milton Road, Cambridge, CB4 0XL, UK Tel: +44 (0)1223 392070