GNU bug report logs - #18612
non-portable shell substitution in configure.ac

Previous Next

Package: emacs;

Reported by: Assaf Gordon <assafgordon <at> gmail.com>

Date: Thu, 2 Oct 2014 19:23:01 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 18612 in the body.
You can then email your comments to 18612 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#18612; Package emacs. (Thu, 02 Oct 2014 19:23:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Assaf Gordon <assafgordon <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 02 Oct 2014 19:23:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Assaf Gordon <assafgordon <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: [platform-testers] Emacs pretest 24.3.94
Date: Thu, 02 Oct 2014 15:22:41 -0400
Hello,

On 10/01/2014 09:13 PM, Glenn Morris wrote:
> The next (and hopefully final) pretest for what will be the 24.4 release
> of Emacs (the extensible text editor) is available at
>
>    ftp://alpha.gnu.org/gnu/emacs/pretest/emacs-24.3.94.tar.xz
>
> Please give it as much testing as you can.

I tested it on few systems, builds OK on all the followings (amd64, with only curses support, no X):
  Debian 7.6
  gNewSense 3.1 (based on Debian 6)
  Ubuntu 14.04.1
  Trisquel 6.0.1 (based on Ubuntu 12.04 LTS)
  OpenSUSE 13.1
  CentOS 6.5
  CentOS 7
  FreeBSD 10
  FreeBSD 9.3
  OpenBSD 5.5
  NetBSD 6.1.4
  DilOS 1.3.7 (OpenSolaris/Illumos-based)
  GNU Hurd/Debian 0.5 (i386)

"./configure" fails on MINIX R3.3.0/i386, but MINIX is not officially supported.

On thing I noticed, is that "configure.ac" (and thus "./configure")
has the following statement (line 38):
    srcdir="/${srcdir:0:1}${srcdir:2}"

I believe these are bash-specific variable expansions, not posix-compatible.

This appears in an MINGW-related "if" block, so I guess most of the time it is not encountered.
But in one instance, I got:
    $ ./configure
    ./configure: 3564: Syntax error: Bad substitution

Regards,
 - Assaf




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18612; Package emacs. (Thu, 02 Oct 2014 19:48:01 GMT) Full text and rfc822 format available.

Message #8 received at 18612 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Assaf Gordon <assafgordon <at> gmail.com>
Cc: 18612 <at> debbugs.gnu.org
Subject: Re: bug#18612: [platform-testers] Emacs pretest 24.3.94
Date: Thu, 02 Oct 2014 22:47:01 +0300
> Date: Thu, 02 Oct 2014 15:22:41 -0400
> From: Assaf Gordon <assafgordon <at> gmail.com>
> 
> On thing I noticed, is that "configure.ac" (and thus "./configure")
> has the following statement (line 38):
>      srcdir="/${srcdir:0:1}${srcdir:2}"
> 
> I believe these are bash-specific variable expansions, not posix-compatible.
> 
> This appears in an MINGW-related "if" block, so I guess most of the time it is not encountered.

MinGW uses only Bash.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18612; Package emacs. (Thu, 02 Oct 2014 20:10:02 GMT) Full text and rfc822 format available.

Message #11 received at 18612 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 18612 <at> debbugs.gnu.org, Assaf Gordon <assafgordon <at> gmail.com>
Subject: Re: bug#18612: [platform-testers] Emacs pretest 24.3.94
Date: Thu, 02 Oct 2014 16:09:24 -0400
Eli Zaretskii wrote:

>>      srcdir="/${srcdir:0:1}${srcdir:2}"
>> 
>> I believe these are bash-specific variable expansions, not posix-compatible.
>> 
>> This appears in an MINGW-related "if" block, so I guess most of the
>> time it is not encountered.
>
> MinGW uses only Bash.

But other platforms may still try to parse (?) those lines, even if they
don't execute them. Presumably that explains:

>> But in one instance, I got:
>>    $ ./configure
>>    ./configure: 3564: Syntax error: Bad substitution

So can you replace it with something portable, eg sed?




Changed bug title to 'non-portable shell substitution in configure.ac' from '[platform-testers] Emacs pretest 24.3.94' Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Thu, 02 Oct 2014 20:17:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18612; Package emacs. (Thu, 02 Oct 2014 21:08:02 GMT) Full text and rfc822 format available.

Message #16 received at 18612 <at> debbugs.gnu.org (full text, mbox):

From: Dani Moncayo <dmoncayo <at> gmail.com>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 18612 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>,
 Assaf Gordon <assafgordon <at> gmail.com>
Subject: Re: bug#18612: [platform-testers] Emacs pretest 24.3.94
Date: Thu, 2 Oct 2014 23:07:17 +0200
On Thu, Oct 2, 2014 at 10:09 PM, Glenn Morris <rgm <at> gnu.org> wrote:
> Eli Zaretskii wrote:
>
>>>      srcdir="/${srcdir:0:1}${srcdir:2}"
>>>
>>> I believe these are bash-specific variable expansions, not posix-compatible.
>>>
>>> This appears in an MINGW-related "if" block, so I guess most of the
>>> time it is not encountered.
>>
>> MinGW uses only Bash.
>
> But other platforms may still try to parse (?) those lines, even if they
> don't execute them. Presumably that explains:
>
>>> But in one instance, I got:
>>>    $ ./configure
>>>    ./configure: 3564: Syntax error: Bad substitution


To find out if that's the case here, Assaf could run the configure
script again, with this patch applied:

--- configure 2014-10-02 22:49:51.808131800 +0200
+++ configure1 2014-10-02 23:05:37.288306300 +0200
@@ -3554,6 +3554,10 @@

 if test "x$MSYSTEM" = "xMINGW32" -o "x$MSYSTEM" = "xMINGW64"
 then
+
+  $as_echo "Too bad.  This should not be executed in this system!.
\$MSYSTEM='$MSYSTEM'" >&2
+  exit 1
+
   . $srcdir/nt/mingw-cfg.site

   case $srcdir in


...and tell us whether the script aborts at that "exit 1", and if so,
the value of $MSYSTEM.

-- 
Dani Moncayo




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18612; Package emacs. (Thu, 02 Oct 2014 22:07:02 GMT) Full text and rfc822 format available.

Message #19 received at 18612 <at> debbugs.gnu.org (full text, mbox):

From: Assaf Gordon <assafgordon <at> gmail.com>
To: Dani Moncayo <dmoncayo <at> gmail.com>, Glenn Morris <rgm <at> gnu.org>
Cc: 18612 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#18612: [platform-testers] Emacs pretest 24.3.94
Date: Thu, 02 Oct 2014 18:06:17 -0400
On 10/02/2014 05:07 PM, Dani Moncayo wrote:
> On Thu, Oct 2, 2014 at 10:09 PM, Glenn Morris <rgm <at> gnu.org> wrote:
>>
>> But other platforms may still try to parse (?) those lines, even if they
>> don't execute them. Presumably that explains:

<...>

> To find out if that's the case here, Assaf could run the configure
> script again, with this patch applied:

The patch itself was not enough, because it still contains the offending lines.
However, I think I managed to reduce the case to this:

=== MINIX R3.3.0 ===
$ sh -c 'echo ${a:0:1}'
sh: Syntax error: Bad substitution
$ sh -c 'true && echo ${a:0:1}'
sh: Syntax error: Bad substitution
$ sh -c 'false && echo ${a:0:1}'
sh: Syntax error: Bad substitution

=== Debian 7.6 ===
$ dash -c 'echo ${a:0:1}'
dash: 1: Bad substitution
$ dash -c 'true && echo ${a:0:1}'
dash: 1: Bad substitution
$ dash -c 'false && echo ${a:0:1}'
(no error printed)

=== NetBSD 6.1.4 ====
$ sh -c 'echo ${a:0:1}'
sh: Syntax error: Bad substitution
$ sh -c 'true && echo ${a:0:1}'
sh: Syntax error: Bad substitution
$ sh -c 'false && echo ${a:0:1}'
sh: Syntax error: Bad substitution

but:

$ ksh -c 'echo ${a:0:1}'
ksh: : bad substitution
$ ksh -c 'true && echo ${a:0:1}'
ksh: : bad substitution
$ ksh -c 'false && echo ${a:0:1}'
(no error printed)
====

The "offending" system is MINIX R3.3.0 (which isn't officially supported).
It is supposed to be MINIX kernel + NetBSD user-space,
so I'm not quite sure why "./configure" on NetBSD works while on MINIX it doesn't.
(something to do with re-exec as "ksh" ? though MINIX does have "/bin/ksh" ).

In any case, I think the examples above demonstrate that MINIX's default shell does parse the shell statements regardless of execution or not, unlike 'dash' or 'ksh'.
I don't know if this is POSIX-compliant-behaviour or not.

Regards,
 - Assaf






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18612; Package emacs. (Thu, 02 Oct 2014 22:12:03 GMT) Full text and rfc822 format available.

Message #22 received at 18612 <at> debbugs.gnu.org (full text, mbox):

From: Assaf Gordon <assafgordon <at> gmail.com>
To: Dani Moncayo <dmoncayo <at> gmail.com>, Glenn Morris <rgm <at> gnu.org>
Cc: 18612 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#18612: [platform-testers] Emacs pretest 24.3.94
Date: Thu, 02 Oct 2014 18:11:41 -0400
On 10/02/2014 06:06 PM, Assaf Gordon wrote:
> The "offending" system is MINIX R3.3.0 (which isn't officially supported).

Just to put things in perspective, even after fixing/avoiding this issue, emacs doesn't build on MINIX as-is,
so this issue shouldn't delay a release...






Reply sent to Paul Eggert <eggert <at> cs.ucla.edu>:
You have taken responsibility. (Thu, 02 Oct 2014 22:34:01 GMT) Full text and rfc822 format available.

Notification sent to Assaf Gordon <assafgordon <at> gmail.com>:
bug acknowledged by developer. (Thu, 02 Oct 2014 22:34:02 GMT) Full text and rfc822 format available.

Message #27 received at 18612-done <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: 18612-done <at> debbugs.gnu.org
Subject: Re:  non-portable shell substitution in configure.ac
Date: Thu, 02 Oct 2014 15:33:17 -0700
Unfortunately POSIX doesn't allow that construction, even in non-executed code, 
so a strict shell is within its rights to reject it.  I installed a simple and 
localized workaround as emacs-24 bzr 117537.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18612; Package emacs. (Thu, 02 Oct 2014 22:49:02 GMT) Full text and rfc822 format available.

Message #30 received at 18612 <at> debbugs.gnu.org (full text, mbox):

From: Dani Moncayo <dmoncayo <at> gmail.com>
To: Assaf Gordon <assafgordon <at> gmail.com>
Cc: Glenn Morris <rgm <at> gnu.org>, Eli Zaretskii <eliz <at> gnu.org>,
 18612 <at> debbugs.gnu.org
Subject: Re: bug#18612: [platform-testers] Emacs pretest 24.3.94
Date: Fri, 3 Oct 2014 00:48:39 +0200
>> To find out if that's the case here, Assaf could run the configure
>> script again, with this patch applied:
>
>
> The patch itself was not enough, because it still contains the offending
> lines.

Of course, because I wanted to determine whether the error was
triggered (a) at parsing time (the shell parses more code than
strictly necessary) or (b) at execution time (some problem with the
test of $MSYSTEM, which provokes the unwanted execution of
MinGW-specific code).

(It seems now clear that the answer is "a".  Thank you)

-- 
Dani Moncayo




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 31 Oct 2014 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 9 years and 201 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.