ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Adamson" <>
Subject Re: ant wrapper script testing
Date Fri, 14 Oct 2016 19:16:06 GMT

A little more cleanup on my part but looking good. Take what you need as I
presume we do not want this merged in directly due to comments, alternative
impls, and testing scripts.

Should I make a new pull request and/or squash this down first?
Is it ready to test by our Solaris/AIX/HPUX users or not until we get it
merged into the mainline repo?

Jeff Adamson

From:	Jeff Adamson/Cleveland/IBM@IBMUS
To:	"Ant Developers List" <>
Date:	10/13/2016 09:54 AM
Subject:	Re: ant wrapper script testing

Things I found out/rediscovered during experiments:
1) `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" echo.
2) `sed` on mac does not support group-0 reference, created an extra
capture group and reference that instead
3) "${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.
4) `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.
5) 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.

1) is awk or sed a better choice for cross platform consistency
2) 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.

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

Jeff Adamson

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

Many thanks for that.

> The only solution I have found to date that avoids all behavior quirks
> 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
> 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/related (inline, None, 0 bytes)
View raw message