zsh-workers
 help / color / mirror / code / Atom feed
b1a2487324e012f41bf5788ac776d34e9ae13231 blob 2876 bytes (raw)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
 
# Test control commands for loops and functions.

%test

  fn3() { return $1; print Error }
  fn2() { fn3 $1 }
  fn() {
    print start $1
    fn2 $1
    return
    print Error
  }
  for val in -1 0 1 255; do
    fn $val; print $?
  done
0:Passing of return values back through functions
>start -1
>-1
>start 0
>0
>start 1
>1
>start 255
>255

  $ZTST_testdir/../Src/zsh -fc 'fn() {
    continue
  }
  fn'
1:continue outside loop
?fn:continue:1: not in while, until, select, or repeat loop

  for outer in 0 1 2 3; do
    print outer $outer
    for inner in 0 1 2 3; do
      print inner $inner
      continue $(( (outer & 1) ? 2 : 1 ))
      print error
    done
    print outer end
  done
0:continue with valid argument
>outer 0
>inner 0
>inner 1
>inner 2
>inner 3
>outer end
>outer 1
>inner 0
>outer 2
>inner 0
>inner 1
>inner 2
>inner 3
>outer end
>outer 3
>inner 0

  for outer in 0 1; do
    continue 0
    print -- $outer got here, status $?
  done
1:continue error case 0
?(eval):continue:2: argument is not positive: 0

  for outer in 0 1; do
    continue -1
    print -- $outer got here, status $?
  done
1:continue error case -1
?(eval):continue:2: argument is not positive: -1

  fn() {
    break
  }
  for outer in 0 1; do
    print $outer
    fn
  done
0:break from within function (this is a feature, I disovered)
>0

  for outer in 0 1 2 3; do
    print outer $outer
    for inner in 0 1 2 3; do
      print inner $inner
      break $(( (outer & 1) ? 2 : 1 ))
      print error
    done
    print outer end
  done
0:break with valid argument
>outer 0
>inner 0
>outer end
>outer 1
>inner 0

  for outer in 0 1; do
    break 0
    print -- $outer got here, status $?
  done
1:break error case 0
?(eval):break:2: argument is not positive: 0

  for outer in 0 1; do
    break -1
    print -- $outer got here, status $?
  done
1:break error case -1
?(eval):break:2: argument is not positive: -1

  false
  for x in; do
    print nothing executed
  done
0:Status 0 from for with explicit empty list

  set --
  false
  for x; do
    print nothing executed
  done
0:Status 0 from for with implicit empty list

  (exit 2)
  for x in 1 2; do
    print $?
  done
0:Status from previous command propagated into for loop
>2
>0

  false
  for x in $(echo 1 2; (exit 3)); do
    print $?
  done
0:Status from expansion propagated into for loop
>3
>0

  false
  for x in $(exit 4); do
    print not executed
  done
0:Status from expansion not propagated after unexecuted for loop
  
  false
  for x in NonExistentFilePrefix*(N); do
    print not executed, either
  done
0:Status from before for loop not propagated if empty after expansion

  for x in $(echo 1; false); do
  done
0:Status reset by empty list in for loop

  false
  for x in $(echo 1; false); do
    echo $?
    (exit 4)  
  done
4:Last status from loop body is kept even with other funny business going on
>1
debug log:

solving b1a2487 ...
found b1a2487 in https://git.vuxu.org/mirror/zsh/

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).