delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2006/04/09/17:44:10

X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f
X-Authenticated: #27081556
From: Juan Manuel Guerrero <juan DOT guerrero AT gmx DOT de>
To: djgpp-workers AT delorie DOT com
Subject: bash and expr difficulty
Date: Sun, 9 Apr 2006 23:54:14 +0200
User-Agent: KMail/1.8.2
MIME-Version: 1.0
Message-Id: <200604092354.14287.juan.guerrero@gmx.de>
X-Y-GMX-Trusted: 0
Reply-To: djgpp-workers AT delorie DOT com

Please look at the following code snippet:

q=0
q=`expr 1 + 1`
echo q=$q

If this shell script is ran with bash 2.05b with LFN support available then
it produces the expected output:

q=2

If the same script is ran from plan DOS (no LFN support) the script fails
with output:

q=

I have recompiled shell utils with debug info enabled and executed the command
expr 1 + 1
with gdb so I can be sure that the failure is not originated by the expr.exe
binary. I have replaced this existing one with this new one and the problem
persists. It seems to be that bash could be  the source of the difficulty but
unfortunatly I have no idea what the reason of this failure could be. I would
appreciate any suggestions concerning this point.
Please note that this questions is not of academic nature. The following code
has been taken from the actual configure script of bison:

  as_lineno_1=$LINENO
  as_lineno_2=$LINENO
  as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
  test "x$as_lineno_1" != "x$as_lineno_2" &&
  test "x$as_lineno_3"  = "x$as_lineno_2"  || {
  # Find who we are.  Look in the path if we contain no path at all
  # relative or not.
[snip]

This code works flawless if LFN support is available but fails if not available.
The third line is the one that fails. This failure implies the execution of the
code inside the openning brace and exits the script with the following error
message:
./configure: line 175: .lineno: No such file or directory (ENOENT)
: error: cannot create .lineno; rerun with a POSIX shell

Of course, on plain DOS a filename with a leading dot is not allowed, but this
is not the real source of the failure of the script. The reason is that line
  as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
does not work as expected if LFN support is not available (plain DOS). And this
failure triggers the code inside the braces producing the described error message.
This kind of configure script will prevent the configuration of GNU packages
on plain DOS. Again any suggestions would be appreciated.

Reagrds,
Juan M. Guerrero

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019