-
Enhancement
-
Resolution: Fixed
-
P4
-
8u45
-
b81
-
x86
-
windows_8
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8142268 | emb-9 | Sundararajan Athijegannathan | P4 | Resolved | Fixed | team |
JDK-8140977 | 8u91 | Sundararajan Athijegannathan | P4 | Resolved | Fixed | b01 |
JDK-8135329 | 8u72 | Sundararajan Athijegannathan | P4 | Closed | Fixed | b01 |
JDK-8147345 | emb-8u91 | Sundararajan Athijegannathan | P4 | Resolved | Fixed | b01 |
A DESCRIPTION OF THE REQUEST :
When I write a script, I want it to fail as soon as one of the commands doesn't return normally (i.e. has non-zero exit code). This functionality is available in other shells, e.g. in bash it's "set -e".
JUSTIFICATION :
This makes scripts safer, by aborting them as soon as a command fails & preventing other commands from causing more harm. A simple example:
cp importantFile anotherFile
rm importantFile
Assuming the first command fails & there's no fail-fast, "importantFile" will be lost.
It also greatly helps in debugging: with this fail-fast behavior, Nashorn could tell exactly which command failed. Without it, a script may run fine for some time after the failed command, and then suddenly crash on a seemingly unrelated command. It may be very hard at that point to find out what went wrong.
Currently, the alternatives are:
- to explicitly check $EXIT after each command. This results in a lot of boilerplate code.
- to create a helper function to wrap all commands. This implies that you have to run all commands by invoking a function, instead of being able to use the much cleaner backticks syntax.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I would like a way to specify fail-fast behavior for Nashorn scripts. It should be possible to specify this in the script itself, so I can just run:
jjs -scripting myNashornScript.js
For example, by introducing a new scripting mode function to set certain options:
set(ABORT_ON_CMD_FAILURE, true);
When I write a script, I want it to fail as soon as one of the commands doesn't return normally (i.e. has non-zero exit code). This functionality is available in other shells, e.g. in bash it's "set -e".
JUSTIFICATION :
This makes scripts safer, by aborting them as soon as a command fails & preventing other commands from causing more harm. A simple example:
cp importantFile anotherFile
rm importantFile
Assuming the first command fails & there's no fail-fast, "importantFile" will be lost.
It also greatly helps in debugging: with this fail-fast behavior, Nashorn could tell exactly which command failed. Without it, a script may run fine for some time after the failed command, and then suddenly crash on a seemingly unrelated command. It may be very hard at that point to find out what went wrong.
Currently, the alternatives are:
- to explicitly check $EXIT after each command. This results in a lot of boilerplate code.
- to create a helper function to wrap all commands. This implies that you have to run all commands by invoking a function, instead of being able to use the much cleaner backticks syntax.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I would like a way to specify fail-fast behavior for Nashorn scripts. It should be possible to specify this in the script itself, so I can just run:
jjs -scripting myNashornScript.js
For example, by introducing a new scripting mode function to set certain options:
set(ABORT_ON_CMD_FAILURE, true);
- backported by
-
JDK-8140977 nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
- Resolved
-
JDK-8142268 nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
- Resolved
-
JDK-8147345 nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
- Resolved
-
JDK-8135329 nashorn should have a "fail-fast" option for scripting, analog to bash "set -e"
- Closed
- relates to
-
JDK-8138906 [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
- Resolved