Bug 192793

Summary: Autoconf-2.59-7 / 2.59-8 has wierd interaction with bash-3.1-6.2 / 3.1-12
Product: [Fedora] Fedora Reporter: TC <tcwan>
Component: autoconfAssignee: Karsten Hopp <karsten>
Status: CLOSED NOTABUG QA Contact: Brian Brock <bbrock>
Severity: medium Docs Contact:
Priority: medium    
Version: 5   
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2006-07-01 20:39:01 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
SRPM for otcl package with configure issue none

Description TC 2006-05-23 03:41:55 UTC
Description of problem:

I'm trying to build otcl package (part of ns2 network simulator).
When running autoconf generated configure script, it'll fail with:

./configure: line 6027: syntax error near unexpected token `('
./configure: line 6027: `    case `(ac_space=' '; set | grep ac_space) 2>&1`
in'error: Bad exit status from /var/tmp/rpm-tmp.70778 (%build)

Version-Release number of selected component (if applicable):

The 'ac_space' string occurs in general.m4 for the _AC_CACHE_DUMP check.
The following is extracted from the configure script which fails:

# The following way of writing the cache mishandles newlines in values,
# but we know of no workaround that is simple, portable, and efficient.
# So, don't put newlines in cache variables' values.
# Ultrix sh set writes to stderr and can't be redirected directly,
# and sets the high bit in the cache file unless we assign to the vars.
{
  (set) 2>&1 |
    case `(ac_space=' '; set | grep ac_space) 2>&1` in
    *ac_space=\ *)
      # `set' does not quote correctly, so add quotes (double-quote
      # substitution turns \\\\ into \\, and sed turns \\ into \).
      sed -n \
	"s/'/'\\\\''/g;
	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
      ;;
    *)
      # `set' quotes correctly as required by POSIX, so do not add quotes.
      sed -n \
	"s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
      ;;
    esac;
} |
  sed '
     t clear
     : clear
     s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
     t end
     /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
     : end' >>confcache
if diff $cache_file confcache >/dev/null 2>&1; then :; else
  if test -w $cache_file; then
    test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file"
    cat confcache >$cache_file
  else
    echo "not updating unwritable cache $cache_file"
  fi
fi
rm -f confcache


How reproducible:

Always.

Steps to Reproduce:
1. Run autoconf on package which loads the _AC_CACHE_DUMP check.
2. execute the configure script
3. configure fails with syntax error
  
Actual results:

syntax error encountered in configure script.

Expected results:

_AC_CACHE_DUMP check will proceed successfully.

Additional info:

If I edit configure script and change the shell in line 1 to /bin/ksh, the
script will run to completion. This indicates that there is some interaction
between bash 3.1 and autoconf which was not present in earlier releases (AFAIK).

I've tried this with the FC5/testing versions of bash and autoconf with the same
results.

Comment 1 Stepan Kasal 2006-06-26 19:03:53 UTC
I tried to reproduce the problem, but did not succeed.

I logged in to an x86_64 FC5 machine which has bash-3.1-6.2 and autoconf-2.59-7,
unpacked a tarball, run
autoconf -f && ./configure && ./configure -C && ./configure -C
and observed no problem.

The configure script contains the code cited above, of course.

"file /bin/bash" says that it is a 64-bit executable.

I'm afraid we need more details to be able to reproduce the bug.

Comment 2 TC 2006-06-27 01:43:04 UTC
Created attachment 131577 [details]
SRPM for otcl package with configure issue

I'm enclosing the SRPM for the otcl package for you. The relevant patch is
patch1 (found after the %build directive). The SPEC file was modified from the
PLD version.

Comment 3 Stepan Kasal 2006-07-01 20:39:01 UTC
Thank you for providing the src rpm.
The following code in configure.in is causing the problem:

    if test -r /etc/.relid -a "X`uname -n`" = "X`uname -s`" ; then
        system=MP-RAS-`awk '{print $3}' /etc/.relid'`
    fi

The second parameter of awk has an unmatched single quote, which confuses the
parser.  Fix that, and bash will work.

The problem is that the two shells parse the errorneous code in different ways.
Ksh matches the two backticks, as intended, and beacuse the if condition is not
true (/etc/.relid does not exist), the bug is covered.

Bash, OTOH, thinks that the second parameter to awk spans several lines.  The
command embedded in backticks is found far below, and the parser is completely
out of sync.

That means that bash skipped lot of code as it it were in that `if', and then
surprised you with an unrelated error message.

That happens often with shell scripts; the trick is to start investigation at
the command which was executed last, and because configure produces a relatively
verbose output, you cah start from the last "checking ..." message.