File: eval.fish

package info (click to toggle)
fish 4.2.1-3.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 35,980 kB
  • sloc: python: 6,972; javascript: 1,407; sh: 1,009; xml: 411; ansic: 230; objc: 78; makefile: 20
file content (84 lines) | stat: -rw-r--r-- 1,766 bytes parent folder | download | duplicates (2)
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
# RUN: %fish %s
# Regression test for issue #4443
eval set -l previously_undefined foo
echo $previously_undefined
# CHECK: foo

# Test redirection
eval "echo you can\\'t see this 1>&2" 2>/dev/null

# Test return statuses
false
eval true
echo $status
# CHECK: 0
false
eval false
echo $status
# CHECK: 1

# Test return status in case of parsing error
false
eval "("
echo $status
# CHECK: 123
# CHECKERR: {{.*}}checks/eval.fish (line {{\d+}}): Unexpected end of string, expecting ')'
# CHECKERR: (
# CHECKERR: ^
false
eval '""'
echo $status
# CHECK: 123
# CHECKERR: {{.*}}checks/eval.fish (line {{\d+}}): The expanded command was empty.
# CHECKERR: ""
# CHECKERR: ^^

function empty
end

# Regression tests for issue #5692
false
eval
echo blank eval: $status # 0
# CHECK: blank eval: 0

false
eval ""
echo empty arg eval: $status # 0
# CHECK: empty arg eval: 0

false
eval empty
echo empty function eval $status # 0
# CHECK: empty function eval 0

false
eval "begin; end;"
echo empty block eval: $status # 0
# CHECK: empty block eval: 0

source /banana/\t/foo
# CHECKERR: source: Error encountered while sourcing file '/banana/\t/foo':
# CHECKERR: source: No such file or directory

# See that eval can't be defined as a function
function eval
    builtin eval $argv
end
# CHECKERR: {{.*}}checks/eval.fish (line {{\d+}}): function: eval: cannot use reserved keyword as function name
# CHECKERR: function eval
# CHECKERR: ^


function evil --no-scope-shadowing
    eval $argv
end

# And this is why we do this: `eval` *can't* be cleanly shadowed with a function,
# because that would always introduce a new block or at the very least clobber $argv.
eval set -l argv this works
echo $argv
# CHECK: this works
evil set -l argv this does not
echo $argv
# CHECK: this works