[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ant-dev
Subject:    Re: ant wrapper script testing
From:       "Jeff Adamson" <jwadamson () us ! ibm ! com>
Date:       2016-11-03 21:39:37
Message-ID: OF5A05F5DC.F647A1FA-ON85258060.0076A60E-85258060.0076FBE5 () notes ! na ! collabserv ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


I agree.
It was nice to have a plan-B if it wasn't too much effort, but probably
should gut awk from the script for now since we know it to be broken on
even one system. We will always have it in history to re-evaluate in the
future if we have more trouble with sed and/or if someone figures out what
is wrong with the awk patterns listed.

Thanks for all your help.

Regards,
Jeff Adamson



From:	Johan Corveleyn <jcorvel@gmail.com>
To:	Ant Developers List <dev@ant.apache.org>
Date:	11/03/2016 06:37 AM
Subject:	Re: ant wrapper script testing



On Mon, Oct 31, 2016 at 9:20 PM, Jeff Adamson <jwadamson@us.ibm.com> wrote:
>
> We will give this more thought. Ant only needs one replacement engine to
work on all platforms, but I don't know of a specific reason that nawk
should not be just as capable as sed.
>
> To summarize,
>
> Using 4-backslash replacement nawk on ubuntu:
>
> arg : -Dfoo=dollar$_backtick`_single'_double"_trailingbackslash\
> quoted_arg: "-Dfoo=dollar\$_backtick\`_single'_double\"_trailingbackslash
\\"
> ....
> [echo] foo=dollar$_backtick`_single'_double"_trailingbackslash\_
>
> Using 8-backslash replacement nawk on ubuntu:
>
> arg : -Dfoo=dollar$_backtick`_single'_double"_trailingbackslash\
> quoted_arg: "-Dfoo=dollar\$_backtick\`_single'_double\"_trailingbackslash
\\\\"
> ....
> [echo] foo=dollar$_backtick`_single'_double"_trailingbackslash\\_
>
> Using 4-backslash replacement nawk(?) on your machine:
>
> arg       : -Dfoo=trail\ingbackslash\
> quoted_arg: "-Dfoo=trail\ingbackslash\"
> ....
> error output (clearly failed to double the backslash during quoting)
>
> Using 8-backslash replacement nawk on your machine:
>
> arg       : -Dfoo=trail\ingbackslash\
> quoted_arg: "-Dfoo=trail\\ingbackslash\\"
> ...
> arg : -Dfoo=trail\ingbackslash\
> quoted_arg: "-Dfoo=trail\\ingbackslash\\"
>
>
> The goal of the line is to replace one backslash literal with two. The
other awk patterns are correctly replacing with two backslashes in the
replacement pattern; introducing a single new backslash literal in the
output. Not sure why this backslash should be different. I think
4-backslash is the correct number unless something is doing an extra pass
of interpretation of the argument.
>
>
> Maybe the slash-string pattern is being interpreted differently. Can we
try it as just plain double-quote strings?
>
> 'awk')
> esc_arg="$(printf '%s' "$esc_arg" | "$awk_exec" '{ gsub("\\\\", "\\\\");
print }' )"
> esc_arg="$(printf '%s' "$esc_arg" | "$awk_exec" '{ gsub("\\$", "\\$");
print }' )"
> esc_arg="$(printf '%s' "$esc_arg" | "$awk_exec" '{ gsub("\"", "\\\"");
print }' )"
> esc_arg="$(printf '%s' "$esc_arg" | "$awk_exec" '{ gsub("`", "\\`");
print }' )"

I'm afraid that doesn't work either:

[[
bash-4.1> diff ant.new ant.new.edited
63,66c63,66
<         esc_arg="$(printf '%s' "$esc_arg" | "$awk_exec" '{
gsub(/\\/, "\\\\"); print }' )"
<         esc_arg="$(printf '%s' "$esc_arg" | "$awk_exec" '{
gsub(/\$/, "\\$");  print }' )"
<         esc_arg="$(printf '%s' "$esc_arg" | "$awk_exec" '{
gsub(/\"/, "\\\""); print }' )"
<         esc_arg="$(printf '%s' "$esc_arg" | "$awk_exec" '{ gsub(/`/,
 "\\`");  print }' )"
---
>         esc_arg="$(printf '%s' "$esc_arg" | "$awk_exec" '{ gsub("\\\\",
"\\\\"); print }' )"
>         esc_arg="$(printf '%s' "$esc_arg" | "$awk_exec" '{ gsub("\\$",
"\\$");  print }' )"
>         esc_arg="$(printf '%s' "$esc_arg" | "$awk_exec" '{ gsub("\"",
"\\\""); print }' )"
>         esc_arg="$(printf '%s' "$esc_arg" | "$awk_exec" '{ gsub("`",
"\\`");  print }' )"
bash-4.1> ./ant.new.edited --execdebug "-Dfoo=trail\\ingbackslash\\" -f
test.xml
arg       : -Dfoo=trail\ingbackslash\
quoted_arg: "-Dfoo=trail\ingbackslash\"
arg       : -f
quoted_arg: "-f"
arg       : test.xml
quoted_arg: "test.xml"
exec "$JAVACMD" -Xmx512m -Djava.awt.headless=true -XX:MaxPermSize=140m
-classpath "$LOCALCLASSPATH" -Dant.home="$ANT_HOME"
-Dant.library.dir="$ANT_LIB"  org.apache.tools.ant.launch.Launcher
-cp "$CLASSPATH"  "-Dfoo=trail\ingbackslash\" "-f" "test.xml"
Buildfile: build.xml does not exist!
Build failed
]]


I think it would indeed be better to focus on 'sed' only now, because
we can get it to work well cross-platform. No need to make it also
work with (n)awk.

--
Johan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org



[Attachment #5 (unknown)]

<html><body><p>I agree. <br>It was nice to have a plan-B if it wasn't too much \
effort, but probably should gut awk from the script for now since we know it to be \
broken on even one system. We will always have it in history to re-evaluate in the \
future if we have more trouble with sed and/or if someone figures out what is wrong \
with the awk patterns listed.<br><br>Thanks for all your \
help.<br><br>Regards,<br>Jeff Adamson<br><br><img width="16" height="16" \
src="cid:1__=0ABB0AF3DFE5209E8f9e8a93df938690918c0AB@" border="0" alt="Inactive hide \
details for Johan Corveleyn ---11/03/2016 06:37:18 AM---On Mon, Oct 31, 2016 at 9:20 \
PM, Jeff Adamson &lt;jwadamson@"><font color="#424282">Johan Corveleyn ---11/03/2016 \
06:37:18 AM---On Mon, Oct 31, 2016 at 9:20 PM, Jeff Adamson \
&lt;jwadamson@us.ibm.com&gt; wrote: &gt;</font><br><br><font size="2" \
color="#5F5F5F">From:        </font><font size="2">Johan Corveleyn \
&lt;jcorvel@gmail.com&gt;</font><br><font size="2" color="#5F5F5F">To:        \
</font><font size="2">Ant Developers List &lt;dev@ant.apache.org&gt;</font><br><font \
size="2" color="#5F5F5F">Date:        </font><font size="2">11/03/2016 06:37 \
AM</font><br><font size="2" color="#5F5F5F">Subject:        </font><font size="2">Re: \
ant wrapper script testing</font><br><hr width="100%" size="2" align="left" noshade \
style="color:#8091A5; "><br><br><br><tt>On Mon, Oct 31, 2016 at 9:20 PM, Jeff Adamson \
&lt;jwadamson@us.ibm.com&gt; wrote:<br>&gt;<br>&gt; We will give this more thought. \
Ant only needs one replacement engine to work on all platforms, but I don't know of a \
specific reason that nawk should not be just as capable as sed.<br>&gt;<br>&gt; To \
summarize,<br>&gt;<br>&gt; Using 4-backslash replacement nawk on \
ubuntu:<br>&gt;<br>&gt; arg : \
-Dfoo=dollar$_backtick`_single'_double&quot;_trailingbackslash\<br>&gt; quoted_arg: \
&quot;-Dfoo=dollar\$_backtick\`_single'_double\&quot;_trailingbackslash\\&quot;<br>&gt; \
....<br>&gt; [echo] foo=dollar$_backtick`_single'_double&quot;_trailingbackslash\_<br>&gt;<br>&gt; \
Using 8-backslash replacement nawk on ubuntu:<br>&gt;<br>&gt; arg : \
-Dfoo=dollar$_backtick`_single'_double&quot;_trailingbackslash\<br>&gt; quoted_arg: \
&quot;-Dfoo=dollar\$_backtick\`_single'_double\&quot;_trailingbackslash\\\\&quot;<br>&gt; \
....<br>&gt; [echo] foo=dollar$_backtick`_single'_double&quot;_trailingbackslash\\_<br>&gt;<br>&gt; \
Using 4-backslash replacement nawk(?) on your machine:<br>&gt;<br>&gt; arg &nbsp; \
&nbsp; &nbsp; : -Dfoo=trail\ingbackslash\<br>&gt; quoted_arg: \
&quot;-Dfoo=trail\ingbackslash\&quot;<br>&gt; ....<br>&gt; error output (clearly \
failed to double the backslash during quoting)<br>&gt;<br>&gt; Using 8-backslash \
replacement nawk on your machine:<br>&gt;<br>&gt; arg &nbsp; &nbsp; &nbsp; : \
-Dfoo=trail\ingbackslash\<br>&gt; quoted_arg: \
&quot;-Dfoo=trail\\ingbackslash\\&quot;<br>&gt; ...<br>&gt; arg : \
-Dfoo=trail\ingbackslash\<br>&gt; quoted_arg: \
&quot;-Dfoo=trail\\ingbackslash\\&quot;<br>&gt;<br>&gt;<br>&gt; The goal of the line \
is to replace one backslash literal with two. The other awk patterns are correctly \
replacing with two backslashes in the replacement pattern; introducing a single new \
backslash literal in the output. Not sure why this backslash should be different. I \
think 4-backslash is the correct number unless something is doing an extra pass of \
interpretation of the argument.<br>&gt;<br>&gt;<br>&gt; Maybe the slash-string \
pattern is being interpreted differently. Can we try it as just plain double-quote \
strings?<br>&gt;<br>&gt; 'awk')<br>&gt; esc_arg=&quot;$(printf '%s' \
&quot;$esc_arg&quot; | &quot;$awk_exec&quot; '{ gsub(&quot;\\\\&quot;, \
&quot;\\\\&quot;); print }' )&quot;<br>&gt; esc_arg=&quot;$(printf '%s' \
&quot;$esc_arg&quot; | &quot;$awk_exec&quot; '{ gsub(&quot;\\$&quot;, \
&quot;\\$&quot;); print }' )&quot;<br>&gt; esc_arg=&quot;$(printf '%s' \
&quot;$esc_arg&quot; | &quot;$awk_exec&quot; '{ gsub(&quot;\&quot;&quot;, \
&quot;\\\&quot;&quot;); print }' )&quot;<br>&gt; esc_arg=&quot;$(printf '%s' \
&quot;$esc_arg&quot; | &quot;$awk_exec&quot; '{ gsub(&quot;`&quot;, &quot;\\`&quot;); \
print }' )&quot;<br><br>I'm afraid that doesn't work \
either:<br><br>[[<br>bash-4.1&gt; diff ant.new ant.new.edited<br>63,66c63,66<br>&lt; \
&nbsp; &nbsp; &nbsp; &nbsp; esc_arg=&quot;$(printf '%s' &quot;$esc_arg&quot; | \
&quot;$awk_exec&quot; '{<br>gsub(/\\/, &quot;\\\\&quot;); print }' )&quot;<br>&lt; \
&nbsp; &nbsp; &nbsp; &nbsp; esc_arg=&quot;$(printf '%s' &quot;$esc_arg&quot; | \
&quot;$awk_exec&quot; '{<br>gsub(/\$/, &quot;\\$&quot;); &nbsp;print }' \
)&quot;<br>&lt; &nbsp; &nbsp; &nbsp; &nbsp; esc_arg=&quot;$(printf '%s' \
&quot;$esc_arg&quot; | &quot;$awk_exec&quot; '{<br>gsub(/\&quot;/, \
&quot;\\\&quot;&quot;); print }' )&quot;<br>&lt; &nbsp; &nbsp; &nbsp; &nbsp; \
esc_arg=&quot;$(printf '%s' &quot;$esc_arg&quot; | &quot;$awk_exec&quot; '{ \
gsub(/`/,<br> &quot;\\`&quot;); &nbsp;print }' )&quot;<br>---<br>&gt; &nbsp; &nbsp; \
&nbsp; &nbsp; esc_arg=&quot;$(printf '%s' &quot;$esc_arg&quot; | \
&quot;$awk_exec&quot; '{ gsub(&quot;\\\\&quot;, &quot;\\\\&quot;); print }' \
)&quot;<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp; esc_arg=&quot;$(printf '%s' \
&quot;$esc_arg&quot; | &quot;$awk_exec&quot; '{ gsub(&quot;\\$&quot;, \
&quot;\\$&quot;); &nbsp;print }' )&quot;<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp; \
esc_arg=&quot;$(printf '%s' &quot;$esc_arg&quot; | &quot;$awk_exec&quot; '{ \
gsub(&quot;\&quot;&quot;, &quot;\\\&quot;&quot;); print }' )&quot;<br>&gt; &nbsp; \
&nbsp; &nbsp; &nbsp; esc_arg=&quot;$(printf '%s' &quot;$esc_arg&quot; | \
&quot;$awk_exec&quot; '{ gsub(&quot;`&quot;, &nbsp;&quot;\\`&quot;); &nbsp;print }' \
)&quot;<br>bash-4.1&gt; ./ant.new.edited --execdebug \
&quot;-Dfoo=trail\\ingbackslash\\&quot; -f test.xml<br>arg &nbsp; &nbsp; &nbsp; : \
-Dfoo=trail\ingbackslash\<br>quoted_arg: &quot;-Dfoo=trail\ingbackslash\&quot;<br>arg \
&nbsp; &nbsp; &nbsp; : -f<br>quoted_arg: &quot;-f&quot;<br>arg &nbsp; &nbsp; &nbsp; : \
test.xml<br>quoted_arg: &quot;test.xml&quot;<br>exec &quot;$JAVACMD&quot; -Xmx512m \
-Djava.awt.headless=true -XX:MaxPermSize=140m<br>-classpath \
&quot;$LOCALCLASSPATH&quot; \
-Dant.home=&quot;$ANT_HOME&quot;<br>-Dant.library.dir=&quot;$ANT_LIB&quot; \
&nbsp;org.apache.tools.ant.launch.Launcher<br>-cp &quot;$CLASSPATH&quot; \
&nbsp;&quot;-Dfoo=trail\ingbackslash\&quot; &quot;-f&quot; \
&quot;test.xml&quot;<br>Buildfile: build.xml does not exist!<br>Build \
failed<br>]]<br><br><br>I think it would indeed be better to focus on 'sed' only now, \
because<br>we can get it to work well cross-platform. No need to make it also<br>work \
with (n)awk.<br><br>-- \
<br>Johan<br><br>---------------------------------------------------------------------<br>To \
unsubscribe, e-mail: dev-unsubscribe@ant.apache.org<br>For additional commands, \
e-mail: dev-help@ant.apache.org<br><br></tt><br><BR> </body></html>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic