This repository has been archived by the owner. It is now read-only.

"node -p" does nothing without -e #3938

Closed
ry opened this Issue Aug 28, 2012 · 5 comments

Comments

Projects
None yet
5 participants

ry commented Aug 28, 2012

23:48 <@ryah> i don't like the "node -p"
23:48 <@ryah> it doesn't make sense
23:48 <@ryah>   -e, --eval script    evaluate script
23:48 <@ryah>   -p, --print          print result of --eval
23:49 <@ryah> -p by itself doesn't do anything
23:49 <@ryah> why not -E  evaluate and print script

@ghost ghost assigned isaacs Aug 28, 2012

Owner

rvagg commented Aug 28, 2012

<ryah> bnoordhuis: back me up here
<bnoordhuis> ryah: actually... i added -pe
Member

piscisaureus commented Aug 28, 2012

[01:37] <@ryah> that horrible
[01:37] <@ryah> 's

@ghost ghost assigned bnoordhuis Aug 28, 2012

isaacs commented Aug 29, 2012

There is some precedent, I guess, as perl requires -p and -e to be separate flags. Of course, in perl, -p adds a while (<>) {...} around the program, and then is in stream-editing mode, sed-like, so it's completely different. (I don't think we ought to have -p wrap your node script in a stdin-reading loop, though a program to do something like perl -pi -e 'program' in node would probably be handy.)

Ruby is exactly the same as perl (since it shares some lineage, it makes sense.)

Python apparently has no way to do this.

Php of course, is completely different, with -R to run a program per input line, -B to run before anything else, -E to run after everything else, and -r to run a single line. No help there.

I think adding an alias for -pe is fine, but capital flags kind of suck. Why not just make -p do this? There's no reason to set -p unless you're going to run a script. It'd be neat if we could have -p print the completion value of the main module, but that would mean making some changes to how we load the main module to use eval instead of a closure.

Member

bnoordhuis commented Aug 29, 2012

I don't have a strong opinion. I guess -p is nice because it's one character less to type. If @ry sends me a sixpack of decent beer (not that horse urine he usually drinks), I'll fix it for him.

@bnoordhuis bnoordhuis closed this in f03c320 Sep 3, 2012

Member

bnoordhuis commented Sep 3, 2012

Fixed in f03c320. Ryan, you have the shipping address, don't you?

sonicdoe added a commit to sonicdoe/npm that referenced this issue Apr 3, 2015

Pass -e to node when using -p
Under Node.js v0.8, `node -p` alone does nothing, see nodejs/node-v0.x-archive#3938.

richardlau pushed a commit to ibmruntimes/node that referenced this issue Dec 18, 2015

2015-12-17, Version 4.2.4 "Argon" (LTS) Release
Maintenance Update

Notable changes

* Roughly 78% of the commits are documentation and test
  improvements
* domains:
  - Fix handling of uncaught exceptions (Julien Gilli)
    [#3884](nodejs/node#3884)
* deps:
  - Upgrade to npm 2.14.12 (Kat Marchán)
    [#4110](nodejs/node#4110)
  - Backport 819b40a from V8 upstream (Michaël Zasso)
    [#3938](nodejs/node#3938)
  - Updated node LICENSE file with new npm license (Kat Marchán)
    [#4110](nodejs/node#4110)

richardlau pushed a commit to ibmruntimes/node that referenced this issue Jan 11, 2016

2015-12-17, Version 4.2.4 "Argon" (LTS) Release
Maintenance Update

Notable changes

* Roughly 78% of the commits are documentation and test
  improvements
* domains:
  - Fix handling of uncaught exceptions (Julien Gilli)
    [#3884](nodejs/node#3884)
* deps:
  - Upgrade to npm 2.14.12 (Kat Marchán)
    [#4110](nodejs/node#4110)
  - Backport 819b40a from V8 upstream (Michaël Zasso)
    [#3938](nodejs/node#3938)
  - Updated node LICENSE file with new npm license (Kat Marchán)
    [#4110](nodejs/node#4110)

richardlau pushed a commit to ibmruntimes/node that referenced this issue Jan 11, 2016

2015-12-23, Version 4.2.4 "Argon" (LTS) Release
Maintenance Update

Notable changes

* Roughly 78% of the commits are documentation and test
  improvements
* domains:
  - Fix handling of uncaught exceptions (Julien Gilli)
    [#3884](nodejs/node#3884)
* deps:
  - Upgrade to npm 2.14.12 (Kat Marchán)
    [#4110](nodejs/node#4110)
  - Backport 819b40a from V8 upstream (Michaël Zasso)
    [#3938](nodejs/node#3938)
  - Updated node LICENSE file with new npm license (Kat Marchán)
    [#4110](nodejs/node#4110)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.