This project is archived and is in readonly mode.
script runner should overwrite $0
-
Ryan Bigg
- State changed from new to incomplete
-
Rohit Arondekar
- State changed from incomplete to open
I've attached a patch that does what Kiyoshi has asked for.
-
Rohit Arondekar
- Tag changed from runner, script to patch, runner, script
Ignore previous patch. This one properly sets $0 and $PROGRAM_NAME to the filename.
-
David Trasbo
+1
I tried it with a fresh Rails 3 app and it works.
I think the variables should be set like
app/models/person.rbinstead of justperson.rb(relatively toRails.root) to be consistent with normal$0and$PROGRAM_NAMEbehavior.
If you, for example, runruby foo/bar/baz.rbthe two variables will both be set tofoo/bar/baz.rb. -
Rohit Arondekar
- Assigned user changed from Ryan Bigg to José Valim
Thanks David. Actually the first patch behaves like that. It will set $0 and $PROGRAM_NAME to the argument passed to runner, in case the file exists.
-
Rohit Arondekar
I couldn't find any tests for Rails Runner. Does it need tests? I wouldn't mind having a go at writing some.
-
José Valim
Hey Rohit, please do add a few tests (at least one for filename and another one for simply passing a string). You can take as base this rake test in Railties:
http://github.com/rails/rails/blob/master/railties/test/application...
-
Rohit Arondekar
I just started on this, but another ticket #4249 [rails3 beta] "rails runner" can't be used in shebang lines has opened up which may change a few things. So I think it's best if I wait?
-
Rohit Arondekar
Attached patch that resolves the issue and also adds 4 tests for runner.
-
Repository
(from [9be0b509628388a290b117e6b02df871d97f8c2d]) Added 4 tests for Rails Runner. 2 failing tests for $0 and $PROGRAM_NAME [#2244 script runner should overwrite $0 state:open]
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/9be0b509628388a290b117e6b02df8... -
Repository
- State changed from open to resolved
(from [40bf76165c392a15cd74321dd7d1cbc96c77bd27]) Rails Runner now sets $0 and $PROGRAM_NAME to name of file being run [#2244 script runner should overwrite $0 state:resolved]
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/40bf76165c392a15cd74321dd7d1cb...
