@@ -68,6 +68,8 @@ static Persistent<String> listeners_symbol;
6868static Persistent<String> uncaught_exception_symbol;
6969static Persistent<String> emit_symbol;
7070
71+
72+ static char *eval_string = NULL ;
7173static int option_end_index = 0 ;
7274static bool use_debug_agent = false ;
7375static bool debug_wait_connect = false ;
@@ -1612,6 +1614,11 @@ static void Load(int argc, char *argv[]) {
16121614
16131615 process->Set (String::NewSymbol (" pid" ), Integer::New (getpid ()));
16141616
1617+ // -e, --eval
1618+ if (eval_string) {
1619+ process->Set (String::NewSymbol (" _eval" ), String::New (eval_string));
1620+ }
1621+
16151622 size_t size = 2 *PATH_MAX;
16161623 char execPath[size];
16171624 if (OS::GetExecutablePath (execPath, &size) != 0 ) {
@@ -1764,6 +1771,13 @@ static void ParseArgs(int *argc, char **argv) {
17641771 } else if (strcmp (arg, " --help" ) == 0 || strcmp (arg, " -h" ) == 0 ) {
17651772 PrintHelp ();
17661773 exit (0 );
1774+ } else if (strcmp (arg, " --eval" ) == 0 || strcmp (arg, " -e" ) == 0 ) {
1775+ if (*argc <= i + 1 ) {
1776+ fprintf (stderr, " Error: --eval requires an argument\n " );
1777+ exit (1 );
1778+ }
1779+ argv[i] = const_cast <char *>(" " );
1780+ eval_string = argv[++i];
17671781 } else if (strcmp (arg, " --v8-options" ) == 0 ) {
17681782 argv[i] = const_cast <char *>(" --help" );
17691783 } else if (argv[i][0 ] != ' -' ) {
0 commit comments