Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8136987

$ENV.PWD is undefined when invoking the script with sudo

    Details

      Description

      FULL PRODUCT VERSION :
      java version "1.8.0_33"
      Java(TM) SE Runtime Environment (build 1.8.0_33-b05)
      Java HotSpot(TM) Client VM (build 25.33-b05, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Linux myhost 3.18.11+ #781 PREEMPT Tue Apr 21 18:02:18 BST 2015 armv6l GNU/Linux


      A DESCRIPTION OF THE PROBLEM :
      $ENV.PWD normally contains the current working directory. However, when the script is invoked with sudo, $ENV.PWD is undefined.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1) create a file "pwd.js" with the following content:
      print($ENV.PWD);

      2) invoke it as usual:
      jjs -scripting pwd.js

      3) invoke it with sudo:
      sudo jjs -scripting pwd.js

      4) for comparison, print the working directory with bash:
      sudo bash -c 'echo $PWD'


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The following output

      /home/pi
      /home/pi
      /home/pi
      ACTUAL -
      The following output:

      /home/pi
      undefined
      /home/pi

      REPRODUCIBILITY :
      This bug can be reproduced always.

        Attachments

          Activity

            People

            • Assignee:
              psonal Pallavi Sonal
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: