jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • Maven 1
  • MAVEN-786

maven Linux shell script incorrectly quotes arguments it passes through to Java

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.1-beta-2
  • Fix Version/s: 1.0.1
  • Component/s: None
  • Labels:
    None
  • Environment:
    Linux (in my case, Mandrake 9.1)

Description

If I want to pass a Java property with a space in it through to my goal,
for example,

maven -e "-Dminestar.release=stable potatoes" zip

maven incorrectly quotes the parameters when passing them to Java resulting in:

BUILD FAILED
Goal "potatoes" does not exist in this project.

HERE'S THE FIX:

Edit the maven shell script. Down the bottom are two lines which say:

$MAIN_CLASS $@

Change them to

$MAIN_CLASS "$@"

This tells the shell to quote parameters individually. The bash manual says:

@ Expands to the positional parameters, starting from one. When
the expansion occurs within double quotes, each parameter
expands to a separate word. That is, "$@" is equivalent to "$1"
"$2" ... When there are no positional parameters, "$@" and $@
expand to nothing (i.e., they are removed).

It took me ages to find this trick for our own system, I know it's confusing as hell.

  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. Text File
    maven.diff
    03/Dec/03 3:43 AM
    0.7 kB
    Joerg Schaible

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
dion gillard added a comment - 24/Sep/03 12:31 AM

Applied suggested fix

Show
dion gillard added a comment - 24/Sep/03 12:31 AM Applied suggested fix
Hide
Permalink
Martin Skopp added a comment - 24/Sep/03 1:57 AM

What about OS other than linux?
What about other shell than bash?

The script in question has

#! /bin/sh

in it's first line, not "#!/bin/bash" which could make a difference on a UNIX which has the original "sh".

I don't know, does the original "sh" also support/require quotes around $@ ? Or should the first line of the script better be changed into "#!/bin/bash" ?

just my .02
Martin

Show
Martin Skopp added a comment - 24/Sep/03 1:57 AM What about OS other than linux? What about other shell than bash? The script in question has #! /bin/sh in it's first line, not "#!/bin/bash" which could make a difference on a UNIX which has the original "sh". I don't know, does the original "sh" also support/require quotes around $@ ? Or should the first line of the script better be changed into "#!/bin/bash" ? just my .02 Martin
Hide
Permalink
dion gillard added a comment - 18/Nov/03 11:43 PM

Re-opened for Martin

Show
dion gillard added a comment - 18/Nov/03 11:43 PM Re-opened for Martin
Hide
Permalink
Martin Skopp added a comment - 20/Nov/03 5:51 AM

dion reported from his memory, the 'fix' broke 'sh' or cygwin or something.
Possible "$@" is not available in original bourne shell, so I suggest the following to determine if bash is active or not:

if [ "$BASH" == "" ]; then

  1. shell is not the bash
    $JAVACMD \
    ...
    $MAIN_CLASS $@
    else
  2. bash its the shell!
    $JAVACMD \
    ...
    $MAIN_CLASS "$@"
    fi

You don't need a real diff, do you dion?

Show
Martin Skopp added a comment - 20/Nov/03 5:51 AM dion reported from his memory, the 'fix' broke 'sh' or cygwin or something. Possible "$@" is not available in original bourne shell, so I suggest the following to determine if bash is active or not: if [ "$BASH" == "" ]; then
  1. shell is not the bash $JAVACMD \ ... $MAIN_CLASS $@ else
  2. bash its the shell! $JAVACMD \ ... $MAIN_CLASS "$@" fi
You don't need a real diff, do you dion?
Hide
Permalink
Joerg Schaible added a comment - 03/Dec/03 3:43 AM

Please reapply as target for this issue the 1.0-BRANCH. This bug already caused me to create a wrong bug report (MAVEN-1058). Attached a patch against the 1.0-BRANCH!

Show
Joerg Schaible added a comment - 03/Dec/03 3:43 AM Please reapply as target for this issue the 1.0-BRANCH. This bug already caused me to create a wrong bug report (MAVEN-1058). Attached a patch against the 1.0-BRANCH!
Hide
Permalink
Joerg Schaible added a comment - 03/Dec/03 3:45 AM

JUst becasue of the comments: This fixes my environment Windows/Cygwin!

Show
Joerg Schaible added a comment - 03/Dec/03 3:45 AM JUst becasue of the comments: This fixes my environment Windows/Cygwin!
Hide
Permalink
Brett Porter added a comment - 23/Sep/04 7:40 PM

was set back to "$@" at some time in the past. I've tested this on cygwin with ash, bash, csh, tcsh
and zsh and all behave in this way. man ash claims System V behaves in this way. If someone has a shell where this
doesn't work, please comment here and reopen. Another option may be to assign it to a variable first: ARGS="$@" ...
$ARGS

Show
Brett Porter added a comment - 23/Sep/04 7:40 PM was set back to "$@" at some time in the past. I've tested this on cygwin with ash, bash, csh, tcsh and zsh and all behave in this way. man ash claims System V behaves in this way. If someone has a shell where this doesn't work, please comment here and reopen. Another option may be to assign it to a variable first: ARGS="$@" ... $ARGS

People

  • Assignee:
    Unassigned
    Reporter:
    John Farrell
Vote (2)
Watch (1)

Dates

  • Created:
    05/Sep/03 12:35 AM
    Updated:
    08/Mar/06 10:47 PM
    Resolved:
    23/Sep/04 7:40 PM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.