fork/fish-shell

git clone https://git.julia.blue/fork/fish-shell

Fabian BoehmPush and pop for-block every run through the loopbf9e5583b

master
1013 B55 linesraw
1# RUN: %fish %s
2
3# A for-loop-variable is a local variable in the enclosing scope.
4set -g i global
5# implicit set -l i $i
6for i in local
7end
8set -ql i && echo $i
9# CHECK: local
10
11# The loop variable is initialized with any previous value.
12set -g j global
13for j in
14end
15set -ql j && echo $j
16# CHECK: global
17
18# Loop variables exist only locally in the enclosing local scope.
19# They do not modify other local/global/universal variables.
20set -g k global
21begin
22    for k in local1
23        echo $k
24        # CHECK: local1
25        for k in local2
26        end
27        echo $k
28        # CHECK: local2
29    end
30    echo $k
31    # CHECK: local1
32end
33echo $k
34# CHECK: global
35
36function foo --on-variable foo
37    echo foo set
38end
39
40for foo in 1 2 3
41    true
42end
43# CHECK: foo set
44# CHECK: foo set
45# CHECK: foo set
46
47for x in 1 2 3
48    test $x -eq 2 && set -l foo bar
49    echo foo value is $foo
50end
51# We keep the old value from outside the loop
52# CHECK: foo value is 3
53# CHECK: foo set
54# CHECK: foo value is bar
55# CHECK: foo value is 3