I have a script that should behave differently depending on what it is called as (think vimdiff
). __filename
is specifically designed to give the real name of the file, following aliases and symlinks and such. Is there a way to get the original开发者_高级运维 command name?
So that if I call:
node_script --foo=bar
Or:
scriptForNode --foo=bar
And they both reference the same code, how can I get the node_script
or scriptForNode
part out?
(Ideally, it should deal with aliases, bash functions, and symlinks equally well, but I'll take what I can get.)
How about process.argv
[0]
?
(Or perhaps that should be process.argv[1]
, since [0] would probably return node
).
精彩评论