zsh-workers
 help / color / mirror / code / Atom feed
397a821f1de1611cf3f8a85142bdec3cc4df2316 blob 1905 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
 
# 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
debug log:

solving 397a821 ...
found 397a821 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).