summary refs log tree commit diff
path: root/Test/D06subscript.ztst
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2007-06-18 13:25:03 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2007-06-18 13:25:03 +0000
commitabae4fe16e26cf027e7c8165d27b93d74bbd18b2 (patch)
tree811bae4da4a0b6f0b370334a7f01ee5d9b9c8baf /Test/D06subscript.ztst
parent5c44b0a472c6e9efdec28ef03337c484b1bc3ce1 (diff)
downloadzsh-abae4fe16e26cf027e7c8165d27b93d74bbd18b2.tar.gz
zsh-abae4fe16e26cf027e7c8165d27b93d74bbd18b2.tar.xz
zsh-abae4fe16e26cf027e7c8165d27b93d74bbd18b2.zip
23562: add KSH_ZERO_SUBSCRIPT option and leave off by default
Diffstat (limited to 'Test/D06subscript.ztst')
-rw-r--r--Test/D06subscript.ztst53
1 files changed, 53 insertions, 0 deletions
diff --git a/Test/D06subscript.ztst b/Test/D06subscript.ztst
index 4dd8a8237..6c9f477cc 100644
--- a/Test/D06subscript.ztst
+++ b/Test/D06subscript.ztst
@@ -182,3 +182,56 @@
   echo X${${l##*}[-1]}X
 0:Negative index applied to substition result from empty array
 >XX
+
+  array=(one two three four)
+  print X$array[0]X
+0:Element zero is empty if KSH_ZERO_SUBSCRIPT is off.
+>XX
+
+  array[0]=fumble
+1:Can't set element zero if KSH_ZERO_SUBSCRIPT is off.
+?(eval):1: array: assignment to invalid subscript range
+
+  print X$array[(R)notfound]X
+0:(R) returns empty if not found if KSH_ZERO_SUBSCRIPT is off.
+>XX
+
+  setopt KSH_ZERO_SUBSCRIPT
+  print X$array[0]X
+0:Element zero is element one if KSH_ZERO_SUBSCRIPT is on.
+>XoneX
+
+  array[0]=fimble
+  print $array
+0:Can set element zero if KSH_ZERO_SUBSCRIPT is on.
+>fimble two three four
+
+  print X$array[(R)notfound]X
+0:(R) yuckily returns the first element on failure withe KSH_ZERO_SUBSCRIPT
+>XfimbleX
+
+  unsetopt KSH_ZERO_SUBSCRIPT
+  array[(R)notfound,(r)notfound]=(help help here come the seventies retreads)
+  print $array
+0:[(R)notfound,(r)notfound] replaces the whole array
+>help help here come the seventies retreads
+
+  string="Why, if it isn't Officer Dibble"
+  print "[${string[0]}][${string[1]}][${string[0,3]}]"
+0:String subscripts with KSH_ZERO_SUBSCRIPT unset
+>[][W][Why]
+
+  setopt KSH_ZERO_SUBSCRIPT
+  print "[${string[0]}][${string[1]}][${string[0,3]}]"
+0:String subscripts with KSH_ZERO_SUBSCRIPT set
+>[W][W][Why]
+
+  unsetopt KSH_ZERO_SUBSCRIPT
+  string[0,3]="Goodness"
+  print $string
+0:Assignment to chunk of string ignores element 0
+>Goodness, if it isn't Officer Dibble
+
+  string[0]=!
+1:Can't set only element zero of string
+?(eval):1: string: assignment to invalid subscript range