最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Node.js: process.argv vs. process.ARGV - Stack Overflow

programmeradmin3浏览0评论

I notice that Node defines both process.argv and process.ARGV (capitalized). The later isn't mentioned in the documentation and is, in every case I've encountered so far, the same object.

Is ARGV just a historic holdover, or does it have a purpose?

I notice that Node defines both process.argv and process.ARGV (capitalized). The later isn't mentioned in the documentation and is, in every case I've encountered so far, the same object.

Is ARGV just a historic holdover, or does it have a purpose?

Share Improve this question asked Apr 28, 2011 at 22:14 Trevor BurnhamTrevor Burnham 77.4k33 gold badges164 silver badges199 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 10

process.ARGV has been removed entirely since v0.5.10.

They are identical:

node

// process.argv
Local<Array> arguments = Array::New(argc - option_end_index + 1);
arguments->Set(Integer::New(0), String::New(argv[0]));
for (j = 1, i = option_end_index; i < argc; j++, i++) {
  Local<String> arg = String::New(argv[i]);
  arguments->Set(Integer::New(j), arg);
}
// assign it
process->Set(String::NewSymbol("ARGV"), arguments);
process->Set(String::NewSymbol("argv"), arguments);

Edit (based on further question):

There's only one person who can tell you that for sure (the author) - you might be able to find him on IRC (irc.freenode #node.js).

Looking through the other symbols, I'd guess that it was added for consistency - argv and env seem to be the only two that have both lower and upper case versions. However, ENV differs slightly from env. Maybe the author thought that argv and ARGV might differ in the same manner as env and ENV?

发布评论

评论列表(0)

  1. 暂无评论