Details

    • Number of attachments :
      0

      Description

      $-W corresponds to the warning level set forth by the -W flag.

      The behavior of this variable is rather strange. If -W is not given, the value is 1:

      $ ruby1.9 -e 'p $-W'
      1
      

      But if you give any of -v, -w or -W (without the argument), the value is 2:

      $ ruby1.9 -v -e 'p $-W'
      ruby 2.0.0dev (2011-11-21 trunk 33804) [x86_64-darwin11.2.0]
      2
      $ ruby1.9 -W -e 'p $-W'
      2
      $ ruby1.9 -w -e 'p $-W'
      2
      

      If you pass an argument to -W, that value is respected:

      $ ruby1.9 -W0 -e 'p $-W'
      0
      $ ruby1.9 -W1 -e 'p $-W'
      1
      $ ruby1.9 -W2 -e 'p $-W'
      2
      

      I am not entirely sure how this variable is supposed to influence the warning output, however.

        Activity

        Hide
        Hiro Asari added a comment - - edited

        This is fixed in bdd8acd.

        $ jruby --1.9 -e 'p $-W'
        1
        $ jruby --1.9 -v -e 'p $-W'
        jruby 1.7.0.dev (ruby-1.9.3-p0) (2011-11-30 bdd8acd) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_29) [darwin-x86_64-java]
        2
        $ jruby --1.9 -w -e 'p $-W'
        2
        $ jruby --1.9 -W -e 'p $-W'
        2
        $ jruby --1.9 -W0 -e 'p $-W'
        0
        $ jruby --1.9 -W1 -e 'p $-W'
        1
        $ jruby --1.9 -W2 -e 'p $-W'
        2
        $ jruby --1.9 -W2 -e 'p $-W = 1'
        NameError: $-W is a read-only variable
          (root) at -e:1
        
        Show
        Hiro Asari added a comment - - edited This is fixed in bdd8acd. $ jruby --1.9 -e 'p $-W' 1 $ jruby --1.9 -v -e 'p $-W' jruby 1.7.0.dev (ruby-1.9.3-p0) (2011-11-30 bdd8acd) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_29) [darwin-x86_64-java] 2 $ jruby --1.9 -w -e 'p $-W' 2 $ jruby --1.9 -W -e 'p $-W' 2 $ jruby --1.9 -W0 -e 'p $-W' 0 $ jruby --1.9 -W1 -e 'p $-W' 1 $ jruby --1.9 -W2 -e 'p $-W' 2 $ jruby --1.9 -W2 -e 'p $-W = 1' NameError: $-W is a read-only variable (root) at -e:1

          People

          • Assignee:
            Hiro Asari
            Reporter:
            Hiro Asari
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: