Commit ff6db71 Andy C
committed
1 parent d303d93 commit ff6db71 Copy full SHA for ff6db71
File tree 3 files changed +13
-12
lines changed
3 files changed +13
-12
lines changed Original file line number Diff line number Diff line change @@ -974,8 +974,8 @@ def Main(
974
974
if not ok :
975
975
return 1
976
976
977
- # Runtime error
978
- if status != 0 :
977
+ # YSH will stop on errors. OSH keep going, a bit like 'source'.
978
+ if status != 0 and exec_opts . errexit () :
979
979
return status
980
980
981
981
#
Original file line number Diff line number Diff line change @@ -106,16 +106,16 @@ They also accept these flags:
106
106
-n Parse the program but don't execute it. Print the AST.
107
107
--ast-format FMT The format for the AST (text|text-abbrev)
108
108
--eval FILE Evaluate the given file, similar to the 'source' builtin.
109
- Specify it multiple times to run multiple files. The
110
- shell stops on normal errors, as well as when $? is
111
- non-zero after evaluating a file (even if errexit is
112
- off).
109
+ Specify it multiple times to run multiple files. If the
110
+ errexit option is on (e.g. in YSH), then the shell stops
111
+ when $? is non-zero after evaluating a file.
113
112
--tool Run a tool instead of the shell (cat-em|syntax-tree)
114
113
115
114
Examples:
116
115
117
- osh -n -c 'hello' # pretty-print the AST
118
- ysh --ast-format text -n -c 'hello' # print it full
116
+ ysh --eval one.ysh --eval two.ysh -c 'echo hi' # Run 2 files first
117
+ osh -n -c 'hello' # pretty-print the AST
118
+ ysh --ast-format text -n -c 'hello' # in unabridged format
119
119
```
120
120
121
121
<h3 id =" config " class =" osh-ysh-topic " >config</h3 >
Original file line number Diff line number Diff line change @@ -100,23 +100,24 @@ echo 'echo one "$@"' > one.sh
100
100
echo ' echo fail "$@"; ( exit 42 )' > fail.sh
101
101
102
102
$SH --eval one.sh \
103
- -c ' echo flag -c "$@"' dummy x y z
103
+ -c ' echo status=$? flag -c "$@"' dummy x y z
104
104
echo
105
105
106
106
# Even though errexit is off, the shell exits if the last status of an --eval
107
107
# file was non-zero.
108
108
109
109
$SH --eval one.sh --eval fail.sh \
110
- -c ' echo flag -c "$@"' dummy x y z
110
+ -c ' echo status=$? flag -c "$@"' dummy x y z
111
111
echo status=$?
112
112
113
113
# # STDOUT:
114
114
one x y z
115
- flag -c x y z
115
+ status=0 flag -c x y z
116
116
117
117
one x y z
118
118
fail x y z
119
- status=42
119
+ status=42 flag -c x y z
120
+ status=0
120
121
# # END
121
122
122
123
# # N-I bash/dash/mksh/zsh STDOUT:
You can’t perform that action at this time.
0 commit comments