Laurent Sansonetti
lsans****@apple*****
Tue Nov 7 18:22:11 JST 2006
Hi Jonathan, Just a quick idea, what about filtering argv and keeping only flags (/ ^-/)? In this way, if you give a filename to a RubyCocoa application, it would be ignored (and we could print a warning to notice the user). And you can still pass -d, which I find very useful. Laurent On Nov 7, 2006, at 8:03 AM, Jonathan Paisley wrote: > Hi all, > > I was just looking at the code in prepare_argv (RBRuntime.m) because > of a rubycocoa-talk post about not being able to get command-line > arguments properly. > > The problem is that if you give a filename on the command line to a > RubyCocoa application, Ruby tries to execute that file rather than > rb_main.rb. > > Looking at prepare_argv: > > ruby_argc = 0; > ruby_argv = malloc (sizeof(char*) * (argc + my_argc + 1)); > for (i = 0; i < argc; i++) { > if (strncmp(argv[i], "-psn_", 5) == 0) continue; > ruby_argv[ruby_argc++] = argv[i]; > } > for (i = 0; i < my_argc; i++) ruby_argv[ruby_argc++] = my_argv[i]; > ruby_argv[ruby_argc] = NULL; > > The command-line arguments are added first, then the "rb_main.rb" > file is appended, from my_argv[]. So the first file that ruby sees is > the one you give on the command line, not rb_main.rb. > > It seems that reversing the order of these operations (putting > "rb_main.rb" first) would help matters. Of course, this then prevents > access to any ruby command-line options (such as '-d'), but these > could be put in RUBYOPT. > > Any comments on this proposal? > > Cheers, > Jonathan > > _______________________________________________ > Rubycocoa-devel mailing list > Rubyc****@lists***** > http://lists.sourceforge.jp/mailman/listinfo/rubycocoa-devel