You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bu...@apache.org on 2016/04/14 17:27:47 UTC

[Bug 59321] New: bootstrap/bin/ant script fails when building ant with syntax error, possibly an un-matched quote

https://bz.apache.org/bugzilla/show_bug.cgi?id=59321

            Bug ID: 59321
           Summary: bootstrap/bin/ant script fails when building ant with
                    syntax error, possibly an un-matched quote
           Product: Ant
           Version: 1.9.7
          Hardware: Sun
                OS: SunOS
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Build Process
          Assignee: notifications@ant.apache.org
          Reporter: dir@obo.org

1.9.6 builds just fine on (uname -a output):
     SunOS rcbuild-solaris10 5.10 Generic_150401-23 i86pc i386 i86pc Solaris

1.9.7 gets an error during the build:
   [snip]
   BUILD SUCCESSFUL
   Total time: 8 seconds
   ... Cleaning Up Build Directories
   ... Done Bootstrapping Ant Distribution
   bootstrap/bin/ant: syntax error at line 339: `end of file' unexpected

'what /bin/sh' shows:
   SunOS 5.10 Generic 142252-02 Sep 2010

I used the same command line to start the build on this SunOS machine for both
1.9.6 and 1.9.7:
   sh build.sh -Ddist.dir=/export/home/drosen/ant dist

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 59321] bootstrap/bin/ant script fails when building ant with syntax error, possibly an un-matched quote

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59321

--- Comment #10 from Jamie Penman-Smithson <jp...@gmail.com> ---
Created attachment 34221
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=34221&action=edit
Escape arguments for Solaris sh

I've managed to get it working using Solaris sh with a few tweaks to the way
that the arguments are escaped, I've attached a patch.

With the limited testing I have done, it appears to work:

$ ant -log"f"ile f"o"o\a.log
Buildfile: [..]
$ ls -al fooa.log
-rw-r--r--   1 devutils other       2445 Sep  7 13:33 fooa.log

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 59321] bootstrap/bin/ant script fails when building ant with syntax error, possibly an un-matched quote

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59321

Stefan Bodewig <bo...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |DUPLICATE
             Status|NEW                         |RESOLVED

--- Comment #17 from Stefan Bodewig <bo...@apache.org> ---
supposed to be fixed with 1.9.8 and 1.10.0

*** This bug has been marked as a duplicate of bug 59898 ***

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 59321] bootstrap/bin/ant script fails when building ant with syntax error, possibly an un-matched quote

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59321

--- Comment #15 from Stefan Bodewig <bo...@apache.org> ---
Unfortunately your patched version doesn't work on Linux :-(

I've asked Jeffrey Adamson over at https://github.com/apache/ant/pull/24 and he
came up with a variabt that at least seems to work across the shell he and I
have tested it (no Solaris, though).

Could you please try the new HEAD version in the master again?

Thanks

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 59321] bootstrap/bin/ant script fails when building ant with syntax error, possibly an un-matched quote

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59321

--- Comment #11 from Jamie Penman-Smithson <jp...@gmail.com> ---
(In reply to Jamie Penman-Smithson from comment #10)
> Created attachment 34221 [details]
> Escape arguments for Solaris sh
> 
> I've managed to get it working using Solaris sh with a few tweaks to the way
> that the arguments are escaped, I've attached a patch.
> 
> With the limited testing I have done, it appears to work:
> 
> $ ant -log"f"ile f"o"o\a.log
> Buildfile: [..]
> $ ls -al fooa.log
> -rw-r--r--   1 devutils other       2445 Sep  7 13:33 fooa.log

I've also tested this on a Linux box (RHEL 6) and it also works there:

$ ant -log"fi"le f\oo"bar".log
Buildfile: build.xml
$ ls -al foobar.log 
-rw-rw-r--. 1 ecat ecat 1.7K Sep  7 13:58 foobar.log

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 59321] bootstrap/bin/ant script fails when building ant with syntax error, possibly an un-matched quote

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59321

--- Comment #5 from Daniel I Lebovitz <da...@hilton.com> ---
Resolved, recommnd moving back to 1.9.6

1.9.7 has an unmatched double quote in the ant script.

 ant_exec_args="$ant_exec_args \"$(printf '%s' "$arg" | sed -e 's@"\|\\@\\\0@g'
)\""

Not sure how I got this in my distribution, but I moved to 1.9.6 with no
problem.  In 1.9.6 the line reads.

ant_exec_args="$ant_exec_args \"$arg\""

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 59321] bootstrap/bin/ant script fails when building ant with syntax error, possibly an un-matched quote

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59321

--- Comment #9 from Stefan Bodewig <bo...@apache.org> ---
Thanks Jamie

we really don't want to require bash for running Ant, so unless we figure out
how to make the script work for "plain sh" I'm more willing to revert to the
wrapper script of 1.9.6 as it worked for way more people.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 59321] bootstrap/bin/ant script fails when building ant with syntax error, possibly an un-matched quote

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59321

Jamie Penman-Smithson <jp...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jpenman.smithson@gmail.com

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 59321] bootstrap/bin/ant script fails when building ant with syntax error, possibly an un-matched quote

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59321

Jamie Penman-Smithson <jp...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |NEW

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 59321] bootstrap/bin/ant script fails when building ant with syntax error, possibly an un-matched quote

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59321

Stefan Bodewig <bo...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |NEW

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 59321] bootstrap/bin/ant script fails when building ant with syntax error, possibly an un-matched quote

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59321

--- Comment #13 from Stefan Bodewig <bo...@apache.org> ---
(In reply to Stefan Bodewig from comment #12)
> Jamie, the current code base contains a change proposed in bug 59898 which
> only add a \n inside the printf. Could you please check whether the script
> of
> https://git-wip-us.apache.org/repos/asf?p=ant.git;a=blob;f=src/script/ant;
> h=043f3fc20f8e26d76761d0efcd9d485078a81cca;hb=HEAD works for you?

more recently updated to also handle backticks and $ signs in
https://git-wip-us.apache.org/repos/asf?p=ant.git;a=blob;f=src/script/ant;hb=HEAD

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 59321] bootstrap/bin/ant script fails when building ant with syntax error, possibly an un-matched quote

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59321

Thomas Stecher <th...@bgr.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |thomas.stecher@bgr.de

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 59321] bootstrap/bin/ant script fails when building ant with syntax error, possibly an un-matched quote

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59321

--- Comment #8 from jpenman.smithson@gmail.com <jp...@gmail.com> ---
I've tried the wrapper script from:

https://git-wip-us.apache.org/repos/asf?p=ant.git;a=blob_plain;f=src/script/ant;h=043f3fc20f8e26d76761d0efcd9d485078a81cca;hb=ad8630572286b10e845e74988b45028af3094266


...and the problem still occurred:

$ ./ant
./ant: syntax error at line 339: `end of file' unexpected

.. tested on:

Solaris 10 10/09 s10x_u8wos_08a X86
Solaris 10 6/06 s10x_u2wos_09a X86

Using bash instead of sh on Solaris works however.

So the diff 'vs' the ant wrapper script in 1.9.7 is:

@@ -1,4 +1,4 @@
-#! /bin/sh
+#! /bin/bash

 # Licensed to the Apache Software Foundation (ASF) under one or more
 # contributor license agreements.  See the NOTICE file distributed with
@@ -36,7 +36,7 @@
       show_help=true
     fi
     # wrap all arguments as "" strings, escape any internal back-slash or
double-quote characters
-    ant_exec_args="$ant_exec_args \"$(printf '%s' "$arg" | sed -e
's@"\|\\@\\\0@g' )\""
+    ant_exec_args="$ant_exec_args \"$(printf '%s\n' "$arg" | sed -e
's@"\|\\@\\\0@g' )\""
   fi
 done

$ ant -version
Apache Ant(TM) version 1.9.7 compiled on April 9 2016

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 59321] bootstrap/bin/ant script fails when building ant with syntax error, possibly an un-matched quote

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59321

--- Comment #1 from Thomas Stecher <th...@bgr.de> ---
This also happens on Linux (tested on SLES12.1)

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 59321] bootstrap/bin/ant script fails when building ant with syntax error, possibly an un-matched quote

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59321

Stefan Bodewig <bo...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO

--- Comment #7 from Stefan Bodewig <bo...@apache.org> ---
This may be a duplicate of Bug 59898 (which has been opened later than this
one, but contained a proposed fix). Could you please give the current wrapper
script
<https://git-wip-us.apache.org/repos/asf?p=ant.git;a=blob_plain;f=src/script/ant;h=043f3fc20f8e26d76761d0efcd9d485078a81cca;hb=ad8630572286b10e845e74988b45028af3094266>
a try and report whether the problem still exists?

Many thanks!

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 59321] bootstrap/bin/ant script fails when building ant with syntax error, possibly an un-matched quote

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59321

Thomas Stecher <th...@bgr.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO

--- Comment #4 from Thomas Stecher <th...@bgr.de> ---
That change works fine. Thanks a lot!

But remember that not all Unix-style OS like Solaris have a bash by default. 

What do we have to do to get this fix getting delivered with the next release?

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 59321] bootstrap/bin/ant script fails when building ant with syntax error, possibly an un-matched quote

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59321

--- Comment #2 from Thomas Stecher <th...@bgr.de> ---
(In reply to Thomas Stecher from comment #1)
> This also happens on Linux (tested on SLES12.1)

That's not completly right. I tried to run the distribution on Solaris and SLES
12.1 and it's broken.

> ./apache-ant-1.9.7/bin/ant
./apache-ant-1.9.7/bin/ant: syntax error at line 339: `end of file' unexpected

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 59321] bootstrap/bin/ant script fails when building ant with syntax error, possibly an un-matched quote

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59321

--- Comment #6 from Stefan Bodewig <bo...@apache.org> ---
There have been two changes to the wrapper script between 1.9.6 and 1.9.7 and
I'd like to figure out, whether only one of them needs to be reverted or
adapted or both of them,

One is commit 568c3ee
https://git-wip-us.apache.org/repos/asf?p=ant.git;a=blobdiff;f=src/script/ant;h=6baf1212b6455eb330094799fff8a45af2778f6d;hp=4c1f7509bb3581b9f6e7e2d4b2842c544a5c473e;hb=568c3eeb96badf1e47380fd3e641cfc9a9ee935e;hpb=14e71c1a93be081c764e2fa54f957b907af6861d
for Bug 58898 and is the one you call out, the other change is commit 14e71c1
https://git-wip-us.apache.org/repos/asf?p=ant.git;a=blobdiff;f=src/script/ant;h=4c1f7509bb3581b9f6e7e2d4b2842c544a5c473e;hp=b5ed5be6a8fe3a08d26dea53ea0fb3f5fab45e3f;hb=14e71c1a93be081c764e2fa54f957b907af6861d;hpb=790987e702966047b786f1fcbbbe554528f09d77
for Bug 58874

It would be great if you could try the wrapper scripts with either patch
applied and tell us which combination breaks the build for you.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 59321] bootstrap/bin/ant script fails when building ant with syntax error, possibly an un-matched quote

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59321

--- Comment #14 from Jamie Penman-Smithson <jp...@gmail.com> ---
On a Solaris system, runninghe version at
https://git-wip-us.apache.org/repos/asf?p=ant.git;a=blob;f=src/script/ant;hb=HEAD
still results in:

$ ./ant -help
./ant: syntax error at line 339: `end of file' unexpected
$

The patched version I attached works without issue.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 59321] bootstrap/bin/ant script fails when building ant with syntax error, possibly an un-matched quote

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59321

--- Comment #12 from Stefan Bodewig <bo...@apache.org> ---
Jamie, the current code base contains a change proposed in bug 59898 which only
add a \n inside the printf. Could you please check whether the script of
https://git-wip-us.apache.org/repos/asf?p=ant.git;a=blob;f=src/script/ant;h=043f3fc20f8e26d76761d0efcd9d485078a81cca;hb=HEAD
works for you?

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 59321] bootstrap/bin/ant script fails when building ant with syntax error, possibly an un-matched quote

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59321

--- Comment #3 from Paolo Alexis Falcone <pf...@itrsgroup.com> ---
An easy workaround is to specify Bash as the default shell:

# diff -ur /usr/ant-1.9.7/bin/ant /tmp/ant
--- /usr/ant-1.9.7/bin/ant      Tue May 17 14:15:43 2016
+++ /tmp/ant    Tue May 17 14:18:23 2016
@@ -1,4 +1,4 @@
-#! /bin/sh
+#! /bin/bash

 # Licensed to the Apache Software Foundation (ASF) under one or more
 # contributor license agreements.  See the NOTICE file distributed with


It seems that "Bash"-isms has creeped inside the ant wrapper script.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 59321] bootstrap/bin/ant script fails when building ant with syntax error, possibly an un-matched quote

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59321

--- Comment #16 from Jamie Penman-Smithson <jp...@gmail.com> ---
I'm afraid that still doesn't work on Solaris:

fnet-oss-uat1% ./ant
./ant: syntax error at line 66: `)' unexpected
fnet-oss-uat1% 

...which appears to be a problem with:

      '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 }' )"                                                                     

(more specifically the last line where it is escaping back-ticks)

-- 
You are receiving this mail because:
You are the assignee for the bug.