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

Nonportable shell constructs cause bin/mvn errors on Debian

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.3.3
    • Fix Version/s: 3.3.9
    • Component/s: Command Line
    • Labels:
      None
    • Environment:

      Description

      bin/mvn includes both local and export commands that perform assignment but do not protect against word splitting. These cause failures on Debian when run in a path with spaces because /bin/sh is dash which performs word splitting for assignment in local and export commands. See discussion here:
      https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=598239

      "Bash and others treat 'local' (just like export, etc) differently, but it's a known shell portability issue."

      For example, in this working directory:

      /home/ben/geoserver/src with spaces/geotools
      

      Running bin/mvn results in:

      $ mvn [options]
      /home/ben/java/maven/bin/mvn: 200: local: spaces/geotools: bad variable name
      [...]
      

      Moving the two local commands in find_maven_basedir to their own lines leaves:

      $ mvn [options]
      /home/ben/java/maven/bin/mvn: 221: export: spaces/geotools: bad variable name
      

      So the export command for MAVEN_PROJECTBASEDIR is also affected, and needs to be moved to the following line. This is a regression because bin/mvn from Maven 3.2.5 worked just fine on Debian in this working directory. Both problems are fixed in the attached patch.

      Another workaround is to change the bin/mvn interpreter from /bin/sh to /bin/bash.

        Attachments

        1. mvn-dash.patch
          0.8 kB
          Ben Caradoc-Davies

          Activity

            People

            • Assignee:
              khmarbaise Karl Heinz Marbaise
              Reporter:
              bencaradocdavies Ben Caradoc-Davies
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: