process: set _print_eval even when --eval is not passed
authorNathan Rajlich <nathan@tootallnate.net>
Tue, 24 Apr 2012 08:24:13 +0000 (01:24 -0700)
committerNathan Rajlich <nathan@tootallnate.net>
Tue, 24 Apr 2012 18:31:02 +0000 (11:31 -0700)
This is for scripts being fed from stdin:

  $ echo "{ foo: 'bar' }" | node -p

src/node.cc

index 7bfcdb8..714dd4c 100644 (file)
@@ -2209,7 +2209,11 @@ Handle<Object> SetupProcessObject(int argc, char *argv[]) {
   // -e, --eval
   if (eval_string) {
     process->Set(String::NewSymbol("_eval"), String::New(eval_string));
-    process->Set(String::NewSymbol("_print_eval"), Boolean::New(print_eval));
+  }
+
+  // -p, --print
+  if (print_eval) {
+    process->Set(String::NewSymbol("_print_eval"), True());
   }
 
   if (force_repl) {