Project

General

Profile

Bug #185

gen-compat-autoconf.sh generates broken compat-autoconf.h header

Added by Anonymous about 7 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
Start date:
05/06/2014
Due date:
% Done:

0%

Estimated time:

Description

Running gen-compat-autoconf.sh generates a broken header file ("compat-autoconf.h"), because the first line contains the invalid characters -n. This causes the build to fail with following error:

compat-autoconf.h:1:1: error: expected identifier or '(' before '-' token

This error is possibly caused by line 8 in the gen-compat-autoconf.sh script. This line does not invoke echo with the -n parameter, instead it outputs -n literally which is then included in the header file and causing the error.

Quote from Stack Overflow (https://stackoverflow.com/questions/13258664/echo-n-will-not-print-n/13258861#13258861):

If you invoke Bash with the name sh, it will mimic sh, where the -n option was not available to echo. (…)

Possible fix:
I think line 8 is redundant, because line 39 would create the file anyway. If you want an alternative (to be sure) I'd suggest to replace line 8 by 'touch "${TMP}"'.

Infos:
System: Mac OS 10.9.2
Bash: GNU bash, version 3.2.51(1)-release (x86_64-apple-darwin13)
Batman: batman-adv-legacy-2014-01-24-e51bd5682e51e6afd8c914686ed675161a75b2d2 from https://github.com/freifunk-gluon/batman-adv-legacy


Files

gen-compat-autoconf.sh-POSIX-compliance.patch (270 Bytes) gen-compat-autoconf.sh-POSIX-compliance.patch Copy patch to root folder and execute with patch -p0 <gen-compat-autoconf.sh-POSIX-compliance.patch Anonymous, 05/07/2014 11:47 AM

History

#1

Updated by Antonio Quartulli about 7 years ago

Hello Martin,

On my laptop (Gentoo Linux) I have bash-4.2_p45. Could this be the reason why you have this problem?

So far you are the first reporting this issue and we always compiled batman-adv on different linux machines using different toolchains of different versions.

#2

Updated by Anonymous about 7 years ago

Hi Antonio,

thanks for your reply! I just upgraded to GNU bash, Version 4.3.11(1)-release (x86_64-apple-darwin13.1.0) and still have this issue.

So far you are the first reporting this issue and we always compiled batman-adv on different linux machines using different toolchains of different versions.

I was already wondering why nobody else encountered this issue, but maybe it's because I'm not using Linux but a BSD-like system…

BTW: Nice to hear there are some Gentoo users out there, currently I'm setting it up on my MacBook ;)

#3

Updated by Antonio Quartulli about 7 years ago

Martin Müller wrote:

... but maybe it's because I'm not using Linux but a BSD-like system…

That is exactly what I have in mind :-)
Maybe their bash port doe snot entirely reflect the mainstream code ?

BTW: Nice to hear there are some Gentoo users out there, currently I'm setting it up on my MacBook ;)

Well, at that point batman-adv should compile properly ;)

#4

Updated by Anonymous about 7 years ago

The important thing is that invoking /bin/sh should give a POSIX compliant shell. 'echo -n' ist NOT POSIX compliant and apparently not all distros/shells set bash into fully POSIX compliant mode properly. The bash reference even states:

As noted above, Bash requires the xpg_echo option to be enabled for the echo builtin to be fully conformant.

The reason why this works on Debian (and maybe other distros) is that they do not fully comply to the POSIX on purpose (see https://www.debian.org/doc/debian-policy/ch-files.html#s-scripts).

To resolve this issue you can either try to comply the POSIX standard to make it work on all POSIX shells, by removing the line (it does not do ything necessary) or use something like touch "${TMP}" or printf '' > "${TMP}". Another possible solution is to use #!/bin/bash as shebang instead.

I also attached a patch ;)

#5

Updated by Marek Lindner over 6 years ago

Martin Müller wrote:

To resolve this issue you can either try to comply the POSIX standard to make it work on all POSIX shells, by removing the line (it does not do ything necessary) or use something like touch "${TMP}" or printf '' > "${TMP}". Another possible solution is to use #!/bin/bash as shebang instead.

The offensive line is used to clear the tmp file in the event of multiple consecutive gen-compat-autoconf.sh runs. Therefore, your patch isn't a good solution.

#6

Updated by Marek Lindner over 6 years ago

  • Status changed from New to Closed

I pushed a fix into the master branch which should satisfy all parties. Feel free to re-open the ticket if you are not happy.

Thanks for reporting the issue!

#7

Updated by Sven Eckelmann over 5 years ago

  • Description updated (diff)
#8

Updated by Sven Eckelmann over 4 years ago

  • Target version set to 2015.1

Also available in: Atom PDF