Uploaded image for project: 'Maven'
  1. Maven
  2. MNG-5852

mvn shell script invokes /bin/sh but requires Bash functions

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.3.3
    • Fix Version/s: 3.5.0-alpha-1, 3.5.0
    • Component/s: Command Line
    • Labels:
      None
    • Environment:
      Solaris 11

      Description

      The bin/mvn script uses the "local" command which is a shell builtin of bash and similar shells, but is not required for POSIX-compliance in sh. When I attempt to run mvn on my Solaris system, I see the following output:

      $ ./mvn
      ./mvn[200]: local: not found [No such file or directory]
      ./mvn[201]: local: not found [No such file or directory]
      ...
      

      Lines 200 and 201 invoke "local" to make local variables to the function. According to "man bash", this is a shell builtin. However, bin/mvn is invoked as:

      #!/bin/sh

      On most flavors of linux, this resolves to bash or dash which probably runs in a restricted environment after checking to see that its $0 is sh. But on Solaris's /bin/sh is actually ksh93 for backwards compatibility.

      Since "local" is not part of a POSIX-compliant /bin/sh, depending on it in a script that is invoked with /bin/sh is a bug.

        Issue Links

          Activity

          Hide
          hudson Hudson added a comment -

          SUCCESS: Integrated in Jenkins build maven-3.x #1531 (See https://builds.apache.org/job/maven-3.x/1531/)
          MNG-5852 mvn shell script invokes /bin/sh but requires Bash functions (michaelo: http://git-wip-us.apache.org/repos/asf/?p=maven.git&a=commit&h=135102022763eaa62fa1d0125adab7ff207ef2f4)

          • (edit) apache-maven/src/bin/mvn
          Show
          hudson Hudson added a comment - SUCCESS: Integrated in Jenkins build maven-3.x #1531 (See https://builds.apache.org/job/maven-3.x/1531/ ) MNG-5852 mvn shell script invokes /bin/sh but requires Bash functions (michaelo: http://git-wip-us.apache.org/repos/asf/?p=maven.git&a=commit&h=135102022763eaa62fa1d0125adab7ff207ef2f4 ) (edit) apache-maven/src/bin/mvn
          Hide
          michael-o Michael Osipov added a comment -
          Show
          michael-o Michael Osipov added a comment - Fixed with 135102022763eaa62fa1d0125adab7ff207ef2f4 .
          Hide
          stephenc Stephen Connolly added a comment -

          Maven 3.4.0 has been dropped. See this thread for more details.

          This issue will need to be re-scheduled for a Maven release in the (hopefully near) future.

          Show
          stephenc Stephen Connolly added a comment - Maven 3.4.0 has been dropped. See this thread for more details. This issue will need to be re-scheduled for a Maven release in the (hopefully near) future.
          Hide
          jhalex Jeffrey Alexander added a comment -

          Thank you, that does work as expected!

          Show
          jhalex Jeffrey Alexander added a comment - Thank you, that does work as expected!
          Hide
          schulte77 Christian Schulte added a comment -

          I am running 'OpenBSD 5.8'. '/bin/sh' also is 'ksh' and works flawlessly. Can you please confirm the following changes to 'apache-maven/src/bin/mvn' solve your issue?

          @@ -197,8 +197,6 @@ fi
           # traverses directory structure from process work directory to filesystem root
           # first directory with .mvn subdirectory is considered project base directory
           find_maven_basedir() {
          -  local basedir
          -  local wdir
             basedir="$(pwd)"
             wdir="$(pwd)"
             while [ "$wdir" != '/' ] ; do
          
          Show
          schulte77 Christian Schulte added a comment - I am running 'OpenBSD 5.8'. '/bin/sh' also is 'ksh' and works flawlessly. Can you please confirm the following changes to 'apache-maven/src/bin/mvn' solve your issue? @@ -197,8 +197,6 @@ fi # traverses directory structure from process work directory to filesystem root # first directory with .mvn subdirectory is considered project base directory find_maven_basedir() { - local basedir - local wdir basedir= "$(pwd)" wdir= "$(pwd)" while [ "$wdir" != '/' ] ; do
          Hide
          t_heit Thorsten Heit added a comment -

          I also saw this output and decided to just remove the word "local" in the shell script to make it work again. So far I haven't hit any problems.

          Show
          t_heit Thorsten Heit added a comment - I also saw this output and decided to just remove the word "local" in the shell script to make it work again. So far I haven't hit any problems.

            People

            • Assignee:
              michael-o Michael Osipov
              Reporter:
              jhalex Jeffrey Alexander
            • Votes:
              2 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development