mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-15 01:17:45 +00:00
38f4330683
Prior to this fix, fish was rather inconsistent in when $status gets set in response to an error. For example, a failed expansion like "$foo[" would not modify $status. This makes the following inter-related changes: 1. String expansion now directly returns the value to set for $status on error. The value is always used. 2. parser_t::eval() now directly returns the proc_status_t, which cleans up a lot of call sites. 3. We expose a new function exec_subshell_for_expand() which ignores $status but returns errors specifically related to subshell expansion. 4. We reify the notion of "expansion breaking" errors. These include command-not-found, expand syntax errors, and others. The upshot is we are more consistent about always setting $status on errors.
26 lines
567 B
Fish
26 lines
567 B
Fish
# RUN: %fish %s
|
|
|
|
# Empty commands should be 123
|
|
set empty_var
|
|
$empty_var
|
|
echo $status
|
|
# CHECK: 123
|
|
# CHECKERR: {{.*}} The expanded command was empty.
|
|
# CHECKERR: $empty_var
|
|
# CHECKERR: ^
|
|
|
|
# Failed expansions
|
|
echo "$abc["
|
|
echo $status
|
|
# CHECK: 121
|
|
# CHECKERR: {{.*}} Invalid index value
|
|
# CHECKERR: echo "$abc["
|
|
# CHECKERR: ^
|
|
|
|
# Failed wildcards
|
|
echo *gibberishgibberishgibberish*
|
|
echo $status
|
|
# CHECK: 124
|
|
# CHECKERR: {{.*}} No matches for wildcard '*gibberishgibberishgibberish*'. {{.*}}
|
|
# CHECKERR: echo *gibberishgibberishgibberish*
|
|
# CHECKERR: ^
|