Closed Bug 718786 Opened 12 years ago Closed 12 years ago

JavaScript shell exits with a zero status when program is terminated

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla12

People

(Reporter: jimb, Unassigned)

Details

Attachments

(1 file)

If the JavaScript shell runs a file (via -f) whose code terminates (that is, execution returns an error, but no exception is set), the shell exits with a zero status. It should only exit with a zero status when all files specified by -f and scripts given using -e complete successfully.

For example:

$ cat foo.js
terminate();
$ cat bar.js
print("Hi, from bar!");
$ js -f foo.js; echo $?
0
$ js -f bar.js; echo $?
Hi, from bar!
0
$ js -f foo.js -f bar.js; echo $?
Hi, from bar!
0
$ 

(Here, 'terminate' is the function defined by the patch in bug 717417.)
Flags: in-testsuite+
OS: Linux → All
Hardware: x86_64 → All
Target Milestone: --- → mozilla13
In js/src/jit-test/jit_test.py, add an 'exitstatus' jit-test cookie
attribute (and rename test.error to test.expect_error). Mark tests that
terminate with their expected termination code.

Clean up TMFLAGS comments.
Attachment #591676 - Flags: review?(jorendorff)
Comment on attachment 591676 [details] [diff] [review]
Make the shell exit with EXITCODE_RUNTIME_ERROR when code is terminated.

Thanks!

I'd even be OK with a bigger change in behavior here, where a single failing -e or -f causes Process to return false, and its caller checks the return value and bails out. Separate bug if so.
Attachment #591676 - Flags: review?(jorendorff) → review+
(In reply to Jason Orendorff [:jorendorff] from comment #2)
> I'd even be OK with a bigger change in behavior here, where a single failing
> -e or -f causes Process to return false, and its caller checks the return
> value and bails out. Separate bug if so.

Actually, every caller of Process already checks gExitCode, so that is the behavior this patch brings about.
https://hg.mozilla.org/mozilla-central/rev/ab3edf81a46f
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: mozilla13 → mozilla12
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: