From 8f20b2361cc2e3911ba67b92f6aa89e7457d17de Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Thu, 18 Nov 2010 13:57:18 +0000 Subject: 28419: Doc/Zsh/expn.yo, Src/subst.c, Test/D04parameter.ztst: KSH_ARRAY ${*:0:1} gives $0, etc. --- Doc/Zsh/expn.yo | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'Doc') 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(}))( -- cgit 1.4.1