summary refs log tree commit diff
path: root/Doc/Zsh
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2010-11-18 13:57:18 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2010-11-18 13:57:18 +0000
commit8f20b2361cc2e3911ba67b92f6aa89e7457d17de (patch)
treeb65be3bf863eb33c6118d0b6326be99832049684 /Doc/Zsh
parent23bdfc7fd2a012d5205ed22d18eb39e41c8fbc95 (diff)
downloadzsh-8f20b2361cc2e3911ba67b92f6aa89e7457d17de.tar.gz
zsh-8f20b2361cc2e3911ba67b92f6aa89e7457d17de.tar.xz
zsh-8f20b2361cc2e3911ba67b92f6aa89e7457d17de.zip
28419: Doc/Zsh/expn.yo, Src/subst.c, Test/D04parameter.ztst:
KSH_ARRAY ${*:0:1} gives $0, etc.
Diffstat (limited to 'Doc/Zsh')
-rw-r--r--Doc/Zsh/expn.yo10
1 files changed, 10 insertions, 0 deletions
diff --git a/Doc/Zsh/expn.yo b/Doc/Zsh/expn.yo
index 6f29a8778..416d46407 100644
--- a/Doc/Zsh/expn.yo
+++ b/Doc/Zsh/expn.yo
@@ -623,6 +623,16 @@ tt(${)var(name)tt(:-)var(word)tt(}) form of substitution; a space
 may be inserted before the tt(-).  Furthermore, neither var(offset) nor
 var(length) may begin with an alphabetic character or tt(&) as these are
 used to indicate history-style modifiers.
+
+For further compatibility with other shells there is a special case
+when the tt(KSH_ARRAYS) option is active, as in emulation of
+Bourne-style shells.  In this case array subscript 0 usually refers to the
+first element of the array.  However, if the substitution refers to the
+positional parameter array, e.g. tt($@) or tt($*), then offset 0
+instead refers to tt($0), offset 1 refers to tt($1), and so on.  In
+other words, the positional parameter array is effectively extended by
+prepending tt($0).  Hence tt(${*:0:1}) substitutes tt($0) and
+tt(${*:1:1}) substitutes tt($1).
 )
 xitem(tt(${)var(name)tt(/)var(pattern)tt(/)var(repl)tt(}))
 item(tt(${)var(name)tt(//)var(pattern)tt(/)var(repl)tt(}))(