Verbose

hi
how can I set the option -w
within the ruby-code?

Thank you
Berg

I googled "set verbose option in ruby code" and this is the first result:

Not sure if it's still in date, the docs will probably tell you more.

Adam

···

On Tue, 10 May 2016 at 14:56 A Berger <aberger7890@gmail.com> wrote:

hi
how can I set the option -w
within the ruby-code?

Thank you
Berg

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

$VERBOSE = true

···

On Tue, May 10, 2016 at 3:56 PM, A Berger <aberger7890@gmail.com> wrote:

hi
how can I set the option -w
within the ruby-code?

--
[guy, jim, charlie].each {|him| remember.him do |as, often| as.you_can
- without end}
http://blog.rubybestpractices.com/

The problem is that setting $VERBOSE doesnt change anything (except storing
the boolean)
Does that work for others??
Thanks Berg

Is there a special purpose that modifying $VERBOSE doesnt change anything?

Why not $ENV (global!) ?

Thanks Berg

Is there a special purpose that modifying $VERBOSE doesnt change anything?

As with all these imprecise statements:

1. what do you think should happen when you set $VERBOSE=true ?

2. what from 1 above does NOT happen?

3. what did you try, to verify that it's not happening?

4. what environment are you using (Ruby implementation/version,
libraries/gems, etc.)

Why not $ENV (global!) ?

Why $ENV?

Thanks Berg

No worries.

···

On 14 May 2016 at 18:25, A Berger <aberger7890@gmail.com> wrote:

--
  Matthew Kerwin
  http://matthew.kerwin.net.au/

Modifying the verbose option does change something, very specific. It sets
the $VERBOSE global variable. The $VERBOSE global variable can then be used
by you for whatever you wish.

In addition to that, Adam Wenham linked to a great post (I certainly
learned a couple things from it) about all the verbose and debug features
of the ruby interpreter, including the fact that the verbose flag causes
uninitialized instance variables to create a runtime warning, which I
thought was quite nifty.

*$ cat > test.rb << EOF*
*heredoc> puts @baloney*
*heredoc> EOF*

*$ ruby test.rb*

*$ ruby --verbose test.rb*
*test.rb:1: warning: instance variable @baloney not initialized*

···

On Sat, May 14, 2016 at 3:37 AM Matthew Kerwin <matthew@kerwin.net.au> wrote:

On 14 May 2016 at 18:25, A Berger <aberger7890@gmail.com> wrote:

Is there a special purpose that modifying $VERBOSE doesnt change anything?

As with all these imprecise statements:

1. what do you think should happen when you set $VERBOSE=true ?

2. what from 1 above does NOT happen?

3. what did you try, to verify that it's not happening?

4. what environment are you using (Ruby implementation/version,
libraries/gems, etc.)

Why not $ENV (global!) ?

Why $ENV?

Thanks Berg

No worries.

--
  Matthew Kerwin
  http://matthew.kerwin.net.au/

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

--

- Raj

Hi

Is there a special purpose that modifying $VERBOSE doesnt change

anything?

As with all these imprecise statements:
1. what do you think should happen when you set $VERBOSE=true ?

Clearly that warnings are displayed.

2. what from 1 above does NOT happening?
3. what did you try, to verify that it's not happening?

(ruby) x.rb:
$VERBOSE=true
i=1 # never used => should warn!
$VERBOSE=false
warn "no no" => should not warn!

So $VERBOSE has no influence...
Can't be possible that this bug is only within my Ruby :wink:
MRI 230p0
Tell me, if someone gets other results!

Why $ENV ?

ENV is global (the same for all classes), so I would say it is (should be)
a global var!

Thanks Berg

···

Am 14.05.2016 12:36 schrieb "Matthew Kerwin" > Berg:

No worries.

--
  Matthew Kerwin

(ruby) x.rb:

$VERBOSE=true
i=1 # never used => should warn!
$VERBOSE=false

warn "no no" => should not warn!

So $VERBOSE has no influence...

$VERBOSE = false to turn off 'warn' won't work. You have to set it to nil.
I've confirmed that this works on Ruby 2.1 on Windows.

I'm still attempting to determine why there's a difference between -w and
$VERBOSE = true.

> Why $ENV ?

ENV is global (the same for all classes), so I would say it is (should be)
a global var!

Thanks Berg

$ENV isn't "global". It sets environment variables for the OS. (I mean, it
*is* global, but the things it creates are not for consumption within Ruby)

···

On Mon, May 16, 2016 at 6:32 AM A Berger <aberger7890@gmail.com> wrote:

Hi,

$VERBOSE = false to turn off 'warn' won't work. You have to set it to

nil.
I've confirmed that this works on Ruby 2.1 on Windows.

Ok thanks - Description in Rubyref (Fitzgerald) is wrong.
If it's true, if -w, than it should be false (the opposite) if not -w.
(If it would be sg other than true, than nil would be ok)

I'm still attempting to determine why there's a difference between -w and

$VERBOSE = true.

> Why $ENV ?

ENV is global (the same for all classes), so I would say it is (should

be) a global var!

Thanks Berg

$ENV isn't "global". It sets environment variables for the OS. (I mean,

it *is* global, but the things it creates are not for consumption within
Ruby)

So it //is// global - in my opinion tells that it should be $ENV
You dont have to consume everything :wink: -- a changed file (e.g. /etc/passwd)
may change the whole system...

bye Berg

···

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

Hi,

> $VERBOSE = false to turn off 'warn' won't work. You have to set it to
nil.
I've confirmed that this works on Ruby 2.1 on Windows.

Ok thanks - Description in Rubyref (Fitzgerald) is wrong.
If it's true, if -w, than it should be false (the opposite) if not -w.
(If it would be sg other than true, than nil would be ok)

There are three possible values for $VERBOSE: true, false, nil. false is

the "default" and gives you warn and all that working as you would expect.
true is supposed to be true verbosity, and nil is "all warnings off". You
can access the three at the command line as -W0, -W1, -W2 (I believe lower
and upper w give the same results). You can also set $VERBOSE in code as
$-w (lower w. upper W won't work).

As near as I can tell, -w imports some sort of linter, which is what gives
the warning on the unused variable. I haven't dug enough to find out what
that linter is.

>
>
> $ENV isn't "global". It sets environment variables for the OS. (I mean,
it *is* global, but the things it creates are not for consumption within
Ruby)

So it //is// global - in my opinion tells that it should be $ENV
You dont have to consume everything :wink: -- a changed file (e.g.
/etc/passwd) may change the whole system...

Setting an environment variable called "$VERBOSE" doesn't mean that Ruby

sees anything as being set. Ruby generally isn't going to look at
environment variables to determine its behavior.

···

On Mon, May 16, 2016 at 7:45 PM A Berger <aberger7890@gmail.com> wrote:

Hi
Very confusing - three (different classes) values for $VERBOSE
My suggestion: 0..2 (as with -W)

I just meant Ruby should have $ENV instead of ENV, because its global.
(ENV is "more" global than $VERBOSE)

Berg