Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
cli: make -p equivalent to -pe
Browse files Browse the repository at this point in the history
Fixes #3938.
  • Loading branch information
bnoordhuis committed Sep 3, 2012
1 parent 7f404e3 commit f03c320
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
16 changes: 7 additions & 9 deletions src/node.cc
Expand Up @@ -2384,20 +2384,18 @@ static void ParseArgs(int argc, char **argv) {
} else if (strcmp(arg, "--help") == 0 || strcmp(arg, "-h") == 0) {
PrintHelp();
exit(0);
} else if (strcmp(arg, "--eval") == 0 || strcmp(arg, "-e") == 0 ||
strcmp(arg, "-pe") == 0) {
} else if (strcmp(arg, "--eval") == 0 ||
strcmp(arg, "-e") == 0 ||
strcmp(arg, "--print") == 0 ||
strcmp(arg, "-pe") == 0 ||
strcmp(arg, "-p") == 0) {
if (argc <= i + 1) {
fprintf(stderr, "Error: --eval requires an argument\n");
fprintf(stderr, "Error: %s requires an argument\n", arg);
exit(1);
}
if (arg[1] == 'p') {
print_eval = true;
}
print_eval = print_eval || strchr(arg, 'p') != NULL;
argv[i] = const_cast<char*>("");
eval_string = argv[++i];
} else if (strcmp(arg, "--print") == 0 || strcmp(arg, "-p") == 0) {
print_eval = true;
argv[i] = const_cast<char*>("");
} else if (strcmp(arg, "--interactive") == 0 || strcmp(arg, "-i") == 0) {
force_repl = true;
argv[i] = const_cast<char*>("");
Expand Down
2 changes: 1 addition & 1 deletion test/simple/test-cli-eval.js
Expand Up @@ -48,7 +48,7 @@ child.exec(nodejs + ' --eval "console.error(42)"',
});

// assert that the expected output is written to stdout
['--print --eval', '-p -e', '-pe'].forEach(function(s) {
'--print -pe -p'.split(' ').forEach(function(s) {
var cmd = nodejs + ' ' + s + ' ';

child.exec(cmd + '42',
Expand Down

0 comments on commit f03c320

Please sign in to comment.