ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Gainty <>
Subject RE: ant wrapper script testing
Date Thu, 13 Oct 2016 15:13:38 GMT
MG>please see quick comment below

Subject: Re: ant wrapper script testing
Date: Thu, 13 Oct 2016 09:53:19 -0400

Things I found out/rediscovered during experiments:

`echo` bash built-in modifies the input (escape interpretation, trailing newline) and not
all versions have options to suppress those behaviors. Using printf instead to get a "clean"
`sed` on mac does not support group-0 reference, created an extra capture group and reference
that instead
"${var/?/Y/Z}" is a perfect substring replacement for our needs. Is supported by bash, zsh,
and ksh93 but is not supported by the dash (ubuntu) or ksh88 (older AIX?) shells.
`awk` and `sed` will both consume trailing newlines and/or whitespace from the input. Resolved
by padding input value with non-whitespace and strip result afterwards. section 2.6.2 of Shell volume documents ${x%w}
${x#w} expansions
The basic code that seems to work for my on ubuntu+dash+gnu_sed and mac+bash+bsd_sed (which
is the default for those platforms):

    esc_arg="$(printf '%s' "$esc_arg" | sed -e 's@\([$"\\`]\)@\\\1@g')"
    esc_arg="${esc_arg#X}" # posix remove single leading X if present 
    esc_arg="${esc_arg%X}" # posix remove single trailing X if present
    ant_exec_args="$ant_exec_args $quoted_arg"

This pattern passes a checkbashisms script cleanly.

is awk or sed a better choice for cross platform consistency                             
                                                                                   did we
still need the trailing newline for sed now that the value is padded? I did not see that as
necessary in my testing on either mac or ubuntu once padded and had removed it.
MG>I *hope* sed utility would read the environment and thus pad 0X0D or 0X0D0x0A depending
on implementing OS
The branch name is a bit of a misnomer since I removed the actuall shell detection, but wanted
to leave that commit in the history locally in case we have reason to adopt that sort of detection.
The trade off is doing ugly'ish zsh/ksh93/bash detection for the benefit of keeping everything
internal and not having the child tools do it.

I have more comments inline
as well as an awk pattern alternative to sed ( commit c591ade4aa7c19ef7e640ed9759fd95e8c4582d8)

MG>speaking of ant can you build above features into

MG>there are many of us who would like the above features incorporated a Xplatform solution
invoked from ant
Jeff Adamson

MG>Many Thanks Jeff (and Stefan)

Stefan Bodewig ---10/12/2016 05:57:39 AM---On 2016-10-11, Jeff Adamson wrote: > I have
been doing some work on trying to correct errors in the

From:        Stefan Bodewig <>
Date:        10/12/2016 05:57 AM
Subject:        Re: ant wrapper script testing

On 2016-10-11, Jeff Adamson wrote:

> I have been doing some work on trying to correct errors in the ant shell
> script with how special characters and whitespace and handled in arguments.

Many thanks for that.

> The only solution I have found to date that avoids all behavior quirks such
> as echo, sed, awk, and whitespace handling is a bashism/ksh/zsh-ism. So
> that does not work for ubuntu's /bin/sh. I have not figured out a universal
> correct script for dash (ubuntu) yet.
> It may be worth detecting those shells to leverage that when we can.

understood. If we are able to get it to work without relying on sed
which seems to be way more platform specific than I had thought, then
I'd prefer such a solution.

> I have run the script with bash, ksh, zsh, and dash under Ubuntu and Mac.
> Csh and tcsh do not seem to work (do we expect them to?)

No, we don't expect the csh family of shells to be able to run /bin/sh


To unsubscribe, e-mail:
For additional commands, e-mail:

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message