Bug 1602209 - Don't assume interactive mode in the JS shell when no file paths are specified. r=jorendorff
authorJan de Mooij <jdemooij@mozilla.com>
Thu, 19 Dec 2019 19:16:02 +0000
changeset 508588 7190108fee043a6caf3d6012740f32c550352cf7
parent 508587 c7082b580eebc04a1c27195783561b68c7ffa954
child 508589 a590ca97f13989c17e649988099e1d4b8aa6c397
push id104095
push userjdemooij@mozilla.com
push dateThu, 02 Jan 2020 07:49:34 +0000
treeherderautoland@7190108fee04 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs1602209
milestone73.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1602209 - Don't assume interactive mode in the JS shell when no file paths are specified. r=jorendorff This fixes the following case to just execute the script instead of using the interactive shell: ``` dist/bin/js < file.js ``` The -i flag can be used to force interactive mode in this case. Differential Revision: https://phabricator.services.mozilla.com/D56334
js/src/shell/js.cpp
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -10190,17 +10190,20 @@ static MOZ_MUST_USE bool ProcessArgs(JSC
       return OptionFailure("binast-format", str);
     }
   }
 #endif  // JS_BUILD_BINAST
 
   if (filePaths.empty() && utf16FilePaths.empty() && codeChunks.empty() &&
       modulePaths.empty() && binASTPaths.empty() &&
       !op->getStringArg("script")) {
-    return Process(cx, nullptr, true, FileScript); /* Interactive. */
+    // Always use the interactive shell when -i is used. Without -i we let
+    // Process figure it out based on isatty.
+    bool forceTTY = op->getBoolOption('i');
+    return Process(cx, nullptr, forceTTY, FileScript);
   }
 
   if (const char* path = op->getStringOption("module-load-path")) {
     RootedString jspath(cx, JS_NewStringCopyZ(cx, path));
     if (!jspath) {
       return false;
     }