Skip to content

Argument quoting prevents expansion of glob expressions and environment variables on macOS #458

@Johennes

Description

@Johennes

On macOS the following configuration results in an error.

<plugins>
  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>3.5.0</version>
    <configuration>
      <skip>${skip.saving.reports}</skip>
    </configuration>
    <executions>
      <execution>
        <id>save_reports</id>
        <phase>post-integration-test</phase>
        <goals>
          <goal>exec</goal>
        </goals>
        <configuration>
          <executable>ls</executable>
          <arguments>
            <argument>src/*</argument>
          </arguments>
          <outputFile>out.log</outputFile>
        </configuration>
      </execution>
    </executions>
  </plugin>
</plugins>
$ cat out.log
ls: src/*: No such file or directory

This is despite the fact that the directory exists and is non-empty on my system:

$ ls src/*
src/main:
java		resources

src/test:
resources

To further illustrate the problem, trying to echo $SHELL will output "$SHELL" rather than expanding the variable.

<goals>
  <goal>exec</goal>
</goals>
<configuration>
  <executable>echo</executable>
  <arguments>
    <argument>$SHELL</argument>
  </arguments>
  <outputFile>out.log</outputFile>
</configuration>
$ cat out.log
$SHELL

I haven't checked any of the plugin's code but my suspicion is that the arguments are quoted which prevents the shell from expanding them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions