tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Cole (JIRA)" <>
Subject [jira] [Updated] (OPENEJB-2065) Change 1482211 causes shell error if bin/openejb is given more than one argument
Date Mon, 06 Jan 2014 06:29:51 GMT


Bill Cole updated OPENEJB-2065:

    Attachment: openejb.patch

This changes in this patch clean up multiple issues in these lines:

54: The -h test option is an archaism, replaced (at least nominally) by -L over 20 years ago.
This change only protects against some future shell that actually removes the old option.

75: Apparently a commented-out debugging line. Pointless in release code. 

77: The OPTIONS variable isn't used after being set and isn't exported, so this line had no

79: The name "OPENEJB_CORE_JAR" was being used in an obfuscatory fashion, since it actually
contained the formatted classpath passed to the java process, consisting of both the openejb-core
and javaee-api JAR files. The prior implementation also used a clumsy mechanism to find the
javaee-api JAR, requiring 2 process forks. My replacement uses more transparent names and
requires no fork to find the javaee-api JAR (echo is a builtin).

81: The only reason to concatenate a string with 'x' (or other nonce) in a shell test is if
you don't use doublequotes around it and it might be null or unset. 

82: OPENEJB_OPTS is used unconditionally in the java invocation and it can be used by a caller
of this script to pass in arbitrary options. The undocumented 'debug' command should not throw
those options away. 

86: Having doublequotes around $args causes the reverse of the problem I originally noted.
A normal shell variable in doublequotes is treated as a single token, even if it has embedded
spaces. Because the java process needs to get the command and its options as distinct arguments,
$args must be used bare. 

> Change 1482211 causes shell error if bin/openejb is given more than one argument
> --------------------------------------------------------------------------------
>                 Key: OPENEJB-2065
>                 URL:
>             Project: OpenEJB
>          Issue Type: Bug
>    Affects Versions: 4.6.0
>         Environment: Any OS with a POSIX shell (sh, ksh, bash, etc) 
>            Reporter: Bill Cole
>            Assignee: Romain Manni-Bucau
>              Labels: easyfix
>             Fix For: 4.6.1
>         Attachments: openejb.patch
>   Original Estimate: 5m
>  Remaining Estimate: 5m
> $@ is always word-split, even inside doublequotes. Hence line 83:
> if [ "x$@" = "xdebug" ]; then
> throws a shell syntax error (in bash "too many arguments", in BSD sh "unexpected operator"
) if the script is given multiple arguments (such as those documented in README.txt) because
"x$@" is expanded to  x$1 $2 [...] $n NOT "x$1 $2 [...] $n"
> The cleanest fix is to change line 83 to:
> if [ "$1" = "debug" ]; then
> This is a precise check for whether the first argument to the script is "debug" and clearly
that's the only relevant argument in such a case, as the "then" clause causes any other args
to be ignored. 

This message was sent by Atlassian JIRA

View raw message