Reputation
202
Top tag
Next privilege 250 Rep.
View close votes
Badges
1 2 10
Impact
~23k people reached

  • 0 posts edited
  • 1 helpful flag
  • 24 votes cast
Mar
27
awarded  Popular Question
Feb
16
asked Why Git Bash always suggests me a `debug` autocompletion?
Feb
2
revised Creating a shebang pointing portably to an interpreter in the folder of a script
added 339 characters in body
Feb
2
comment Creating a shebang pointing portably to an interpreter in the folder of a script
I actually use iojs which is a fork of node (but still has node executable for backward compat reasons); It enables V8 engine experimental features to run; see node --v8-options
Feb
2
awarded  Yearling
Feb
1
comment Creating a shebang pointing portably to an interpreter in the folder of a script
Nope it doesn't; you can test with a simple JS file being console.log(process.argv) and then node file.js -q vs echo console.log(process.argv) | node -q. The latter fails with "bad option: -q". Also the sed hack makes the script work fine when run as ./file.js but makes it fail when run as node ./file.js. I guess there can't be produced a good workaround following this way.
Feb
1
comment Creating a shebang pointing portably to an interpreter in the folder of a script
I just realized your hack is not bulletproof since it prohibits passing the parameters to the script. E.g. ./file.js -param, normally this sets process.argv[2] == "-param", but when piping the script text to the node interpreter, this gets lost. Making this work would probably need even more hacks, not sure I need it that much ;)
Feb
1
comment Creating a shebang pointing portably to an interpreter in the folder of a script
Interesting but doesn't work on Windows, AFAIK // is used by Git Bash as the prefix for network shares (equivalent to \\ prefix in Windows).
Feb
1
awarded  Commentator
Feb
1
comment Creating a shebang pointing portably to an interpreter in the folder of a script
That's pretty hacky but it worked for me (sed '1,2d' "$0" | node --harmony_arrow_functions ; exit $?), +1, thanks :)
Feb
1
comment Creating a shebang pointing portably to an interpreter in the folder of a script
I used $0 instead of $@ to pass the original file name, but anyway this solution does not work, see my edit
Feb
1
revised Creating a shebang pointing portably to an interpreter in the folder of a script
added 593 characters in body
Feb
1
revised Creating a shebang pointing portably to an interpreter in the folder of a script
added 43 characters in body
Feb
1
asked Creating a shebang pointing portably to an interpreter in the folder of a script
Jul
27
awarded  Nice Question
Jul
15
awarded  Famous Question
Dec
10
accepted Matching two different lines that are at least N lines distant from each other
Dec
9
revised Matching two different lines that are at least N lines distant from each other
added 158 characters in body
Dec
9
asked Matching two different lines that are at least N lines distant from each other
Nov
22
accepted `find` with multiple `-name` and `-exec` executes only the last matches of `-name`