* Re: Evaluation of $# - bug?
[not found] <200012041133.MAA05780@beta.informatik.hu-berlin.de>
@ 2000-12-04 11:57 ` Peter Stephenson
2000-12-04 16:04 ` Bart Schaefer
0 siblings, 1 reply; 2+ messages in thread
From: Peter Stephenson @ 2000-12-04 11:57 UTC (permalink / raw)
To: Zsh hackers list
> 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(#) <S>)(
-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) <S> <Z>)(
--
Peter Stephenson <pws@csr.com> Software Engineer
Cambridge Silicon Radio, Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK Tel: +44 (0)1223 392070
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Evaluation of $# - bug?
2000-12-04 11:57 ` Evaluation of $# - bug? Peter Stephenson
@ 2000-12-04 16:04 ` Bart Schaefer
0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2000-12-04 16:04 UTC (permalink / raw)
To: Zsh hackers list
} Sven wrote:
} > Use `${#}-1'.
Or even `$# -1', if you're performing arithmetic rather than concatenation.
On Dec 4, 11:57am, Peter Stephenson wrote:
}
} +sequence `tt($#-)var(...)' in an arithmetic expression is interpreted as
Whether it's in an arithmetic expression is immaterial, isn't it?
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2000-12-04 16:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <200012041133.MAA05780@beta.informatik.hu-berlin.de>
2000-12-04 11:57 ` Evaluation of $# - bug? Peter Stephenson
2000-12-04 16:04 ` Bart Schaefer
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).