On Wed, 13 Oct 2010 10:48:46 -0700, Paul Berry wrote:
> Date: Wed, 13 Oct 2010 10:48:46 -0700
> From: Paul Berry <[email protected]>
> To: [email protected]
> Subject: Re: [Puppet-dev] [PATCH/facter 1/1] Add "exit" lost in merge
>  conflict
>  resolution fix for application.rb
> Message-ID: <[email protected]>
> 
> On Mon, Oct 11, 2010 at 1:23 PM, Jacob Helwig <[email protected]> wrote:
> 
> > Re-add the "exit" lost in f4da528.  Both sides of the original merge had
> > the explicit exit in the success case around RDoc.usage.
> >
> > Signed-off-by: Jacob Helwig <[email protected]>
> > ---
> >
> > Rein,
> >
> > Sorry for taking so long to get this off to you.
> >
> > From looking at
> > dce8f5727c4b6ee0332500c189775cc7c036e6d0^1:lib/facter/application.rb
> > and
> > dce8f5727c4b6ee0332500c189775cc7c036e6d0^2:lib/facter/application.rb
> > it looks like the exit should have been left there.
> >
> > If that's not the case, though, just let me know.
> >
> > Available at:
> >
> > git://github.com/jhelwig/facter.git testing
> >
> >  lib/facter/application.rb |    1 +
> >  1 files changed, 1 insertions(+), 0 deletions(-)
> >
> > diff --git a/lib/facter/application.rb b/lib/facter/application.rb
> > index 9de9249..6c5b1dd 100644
> > --- a/lib/facter/application.rb
> > +++ b/lib/facter/application.rb
> > @@ -73,6 +73,7 @@ module Facter
> >             require 'rdoc/ri/ri_paths'
> >             require 'rdoc/usage'
> >             puts RDoc.usage
> > +            exit
> >           rescue LoadError
> >             $stderr.puts "No help available unless your RDoc has
> > RDoc.usage"
> >             exit(1)
> > --
> > 1.7.3.1
> >
> 
> Reading this code, it looks like RDoc.usage returns the usage string.
>  Actually, what it does is print the usage string and exit.  (This is
> obliquely hinted at in the documentation--see
> http://ruby-doc.org/core/classes/RDoc.html#M004706, and I've verified it by
> experiment).  As a result, the code above works by accident, with or without
> the "exit" statement.  To avoid future confusion perhaps it would be better
> to do something like this:
> 
> diff --git a/lib/facter/application.rb b/lib/facter/application.rb
> index 9de9249..56827ec 100644
> --- a/lib/facter/application.rb
> +++ b/lib/facter/application.rb
> @@ -72,7 +72,7 @@ module Facter
>            begin
>              require 'rdoc/ri/ri_paths'
>              require 'rdoc/usage'
> -            puts RDoc.usage
> +            RDoc.usage # print usage and exit
>            rescue LoadError
>              $stderr.puts "No help available unless your RDoc has
> RDoc.usage"
>              exit(1)
> 

Yeah, looks like the explilcit exit was never actually reached.  +1 for
Paul's version.

-- 
Jacob Helwig

Attachment: signature.asc
Description: Digital signature

Reply via email to