From unknown Sat Sep 20 13:01:01 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#10436 <10436@debbugs.gnu.org> To: bug#10436 <10436@debbugs.gnu.org> Subject: Status: New testsuite driver and extra trailing backslash in recipes (was: Re: bug#10427: coreutils-8.14.116-1e18d: testsuite failures on NetBSD 5.1) Reply-To: bug#10436 <10436@debbugs.gnu.org> Date: Sat, 20 Sep 2025 20:01:01 +0000 retitle 10436 New testsuite driver and extra trailing backslash in recipes = (was: Re: bug#10427: coreutils-8.14.116-1e18d: testsuite failures on NetBSD= 5.1) reassign 10436 automake submitter 10436 Stefano Lattarini severity 10436 normal tag 10436 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Thu Jan 05 07:51:29 2012 Received: (at submit) by debbugs.gnu.org; 5 Jan 2012 12:51:29 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Rimn2-0000qJ-KF for submit@debbugs.gnu.org; Thu, 05 Jan 2012 07:51:29 -0500 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Rimn0-0000qC-Ko for submit@debbugs.gnu.org; Thu, 05 Jan 2012 07:51:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RimjX-0000ZB-Nc for submit@debbugs.gnu.org; Thu, 05 Jan 2012 07:47:56 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,T_DKIM_INVALID autolearn=unavailable version=3.3.2 Received: from lists.gnu.org ([140.186.70.17]:47925) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RimjX-0000Z2-Ib for submit@debbugs.gnu.org; Thu, 05 Jan 2012 07:47:51 -0500 Received: from eggs.gnu.org ([140.186.70.92]:43039) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RimjV-0006XI-Km for bug-automake@gnu.org; Thu, 05 Jan 2012 07:47:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RimjT-0000Y1-Cm for bug-automake@gnu.org; Thu, 05 Jan 2012 07:47:49 -0500 Received: from mail-ey0-f169.google.com ([209.85.215.169]:45228) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RimjS-0000Xi-TL for bug-automake@gnu.org; Thu, 05 Jan 2012 07:47:47 -0500 Received: by eabm6 with SMTP id m6so401575eab.0 for ; Thu, 05 Jan 2012 04:47:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; bh=Lyt4s/KnRu07XnnuiLJK51crQHiqRRNw9VRSJSDC208=; b=w0t721IxnRJWYqoNTJAtvRJmonyDmu5S6587PpKWZxARxqIMCOL/e0PzIg8qDTAUfh d+Fu+UMbBbtB/9hwEERhB3rmIS7hDyEWLYFWnXcnTty+BFzVb3wROModHNgn6CQf+t0H Ds/BEh6O2kt4A6p+xPCXBLmvmTp2hP00Qx21U= Received: by 10.204.153.27 with SMTP id i27mr703368bkw.81.1325767665370; Thu, 05 Jan 2012 04:47:45 -0800 (PST) Received: from [82.54.101.15] (host15-101-dynamic.54-82-r.retail.telecomitalia.it. [82.54.101.15]) by mx.google.com with ESMTPS id fg16sm113633835bkb.16.2012.01.05.04.47.44 (version=SSLv3 cipher=OTHER); Thu, 05 Jan 2012 04:47:44 -0800 (PST) Message-ID: <4F059BE8.6000107@gmail.com> Date: Thu, 05 Jan 2012 13:47:36 +0100 From: Stefano Lattarini MIME-Version: 1.0 To: Paul Eggert Subject: New testsuite driver and extra trailing backslash in recipes (was: Re: bug#10427: coreutils-8.14.116-1e18d: testsuite failures on NetBSD 5.1) References: <87aa64k902.fsf@rho.meyering.net> <4F033BB0.4090305@gmail.com> <4F0566B3.2030104@cs.ucla.edu> In-Reply-To: <4F0566B3.2030104@cs.ucla.edu> Content-Type: multipart/mixed; boundary="------------010908040805020807010504" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.17 X-Spam-Score: -5.2 (-----) X-Debbugs-Envelope-To: submit Cc: bug-automake@gnu.org, jim@meyering.net, 10427@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.3 (-----) This is a multi-part message in MIME format. --------------010908040805020807010504 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit [adding bug-automake in CC:] Reference: Hi Paul, thanks for the report and diagnosis. On 01/05/2012 10:00 AM, Paul Eggert wrote: > I'm sending this to bug-automake because I think it's an automake > issue. However, the problem causes the latest coreutils snapshot > to fail to build, so I'm CC'ing to bug-coreutils. > >> On 01/03/2012 06:10 PM, Jim Meyering wrote: >>> FYI, here's a snapshot of what will soon be coreutils-8.15, >>> expected on Thursday or Friday. >>> >>> coreutils snapshot: >>> http://meyering.net/cu/coreutils-ss.tar.xz 5.2 MB >>> http://meyering.net/cu/coreutils-ss.tar.xz.sig >>> http://meyering.net/cu/coreutils-8.14.116-1e18d.tar.xz > > This snapshot doesn't build on Solaris 8 (sparc) with native tools, > for a couple of reasons. I don't expect Solaris 8 is an active > porting target any more, but these problems could well happen on > active targets. > I agree that this issues might prove a liability on some modern systems too, and that we should fix them. (BTW, if you feel like running the whole automake testsuite on Solaris 8 to find more similar issues, I wouldn't object ;-) > First, there's code like this in tests/Makefile.in: > > $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) "$$tst" \ > $(AM_TESTS_FD_REDIRECT) > > This code is generated by Automake. Here, AM_TESTS_FD_REDIRECT > is empty. Solaris 8 'make' executes the above as follows: > > bash -c '[expansion of previous line] \' > > and Bash complains about a syntax error with the trailing backslash. > I can reproduce this with bash 2.05b on Debian. Attached is a fix for this bug, with a testcase. The test is quite elaborate and somewhat hacky, but I'd rather keep it anyway, since I'm planning to refactor it into an external helper script that will be used to guard against other unwanted trailing `\' in *all* the make recipes run in the automake testsuite (that's for a follow-up patch obviously). > How about changing Automake to generate something like this instead, > with no backslash-newline? > > $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) "$$tst" $(AM_TESTS_FD_REDIRECT) > > This should avoid the problem. > I ended up breaking the line in a "safer" place instead. It is enough to fix the bug. Regards, Stefano --------------010908040805020807010504 Content-Type: text/x-diff; name="0001-parallel-tests-avoid-trailing-backslashes-in-make-re.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-parallel-tests-avoid-trailing-backslashes-in-make-re.pa"; filename*1="tch" >From 7902852607b596d1a341501d1823da826fb4b4ed Mon Sep 17 00:00:00 2001 Message-Id: <7902852607b596d1a341501d1823da826fb4b4ed.1325767602.git.stefano.lattarini@gmail.com> From: Stefano Lattarini Date: Thu, 5 Jan 2012 13:41:13 +0100 Subject: [PATCH] parallel-tests: avoid trailing backslashes in make recipes The new testsuite-harness could generate recipes with a trailing backslash character (possibly followed by blank characters only), in the very common case where the user hadn't defined the special $(AM_TESTS_FD_REDIRECT) variable. This caused spurious syntax errors with at least older bash versions (e.g., bash 2.05b), and could be potentially unportable to other weaker shells. See automake bug#xxx: and coreutils bug#10427: * lib/am/check2.am: Rework line breaks so that no backslash can be at the end of a line. * tests/parallel-tests-trailing-bslash.test: New test. * tests/list-of-tests.mk: Add it. --- lib/am/check2.am | 10 +- tests/list-of-tests.mk | 1 + tests/parallel-tests-trailing-bslash.test | 115 +++++++++++++++++++++++++++++ 3 files changed, 121 insertions(+), 5 deletions(-) create mode 100755 tests/parallel-tests-trailing-bslash.test diff --git a/lib/am/check2.am b/lib/am/check2.am index ad0a4aa..9a0fe9d 100644 --- a/lib/am/check2.am +++ b/lib/am/check2.am @@ -1,5 +1,5 @@ ## automake - create Makefile.in from Makefile.am -## Copyright (C) 2008, 2009, 2011 Free Software Foundation, Inc. +## Copyright (C) 2008, 2009, 2011, 2012 Free Software Foundation, Inc. ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -19,8 +19,8 @@ ?!GENERIC?%OBJ%: %SOURCE% @p='%SOURCE%'; $(am__check_pre) %DRIVER% --test-name "$$f" \ --log-file '%BASE%.log' --trs-file '%BASE%.trs' \ - $(am__common_driver_flags) %DRIVER_FLAGS% -- %COMPILE% "$$tst" \ - $(AM_TESTS_FD_REDIRECT) + $(am__common_driver_flags) %DRIVER_FLAGS% -- %COMPILE% \ + "$$tst" $(AM_TESTS_FD_REDIRECT) ## If no programs are built in this package, then this rule is removed ## at automake time. Otherwise, %am__EXEEXT% expands to a configure time @@ -30,6 +30,6 @@ if %am__EXEEXT% ?GENERIC?%EXT%$(EXEEXT).log: @p='%SOURCE%'; $(am__check_pre) %DRIVER% --test-name "$$f" \ --log-file '%BASE%.log' --trs-file '%BASE%.trs' \ - $(am__common_driver_flags) %DRIVER_FLAGS% -- %COMPILE% "$$tst" \ - $(AM_TESTS_FD_REDIRECT) + $(am__common_driver_flags) %DRIVER_FLAGS% -- %COMPILE% \ + "$$tst" $(AM_TESTS_FD_REDIRECT) endif %am__EXEEXT% diff --git a/tests/list-of-tests.mk b/tests/list-of-tests.mk index 8b4f2ca..dbadfdc 100644 --- a/tests/list-of-tests.mk +++ b/tests/list-of-tests.mk @@ -709,6 +709,7 @@ parallel-tests-no-spurious-summary.test \ parallel-tests-exit-statuses.test \ parallel-tests-console-output.test \ parallel-tests-once.test \ +parallel-tests-trailing-bslash.test \ tests-environment.test \ am-tests-environment.test \ tests-environment-backcompat.test \ diff --git a/tests/parallel-tests-trailing-bslash.test b/tests/parallel-tests-trailing-bslash.test new file mode 100755 index 0000000..cd15600 --- /dev/null +++ b/tests/parallel-tests-trailing-bslash.test @@ -0,0 +1,115 @@ +#! /bin/sh +# Copyright (C) 2012 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Check that the new testsuite-harness do not generate recipes that can +# have a trailing `\', since that can cause spurious syntax errors with +# older bash versions (e.g., bash 2.05b). +# See automake bug#xxx. + +am_parallel_tests=yes +. ./defs || Exit 1 + +echo AC_OUTPUT >> configure.in + +cat > Makefile.am <<'END' +TESTS = foo.test +EXTRA_DIST = $(TESTS) +am__backslash = \\ # foo +.PHONY: bad-recipe +bad-recipe: + @printf '%s\n' $(am__backslash) +END + +cat > foo.test <<'END' +#!/bin/sh +exit 0 +END +chmod +x foo.test + +am__SHELL=$SHELL; export am__SHELL +am__PERL=$PERL; export am__PERL + +cat > my-shell <<'END' +#!/bin/sh -e +set -u +tab=' ' +nl=' +' +am__shell_flags= +am__shell_command=; unset am__shell_command +while test $# -gt 0; do + case $1 in + # If the shell is invoked by make e.g. as "sh -ec" (seen on + # GNU make in POSIX mode) or "sh -ce" (seen on Solaris make). + -*c*) + flg=`echo x"$1" | sed -e 's/^x-//' -e 's/c//g'` + if test x"$flg" != x; then + am__shell_flags="$am__shell_flags -$flg" + fi + am__shell_command=$2 + shift + ;; + -?*) + am__shell_flags="$am__shell_flags $1" + ;; + *) + break + ;; + esac + shift +done +if test x${am__shell_command+"set"} != x"set"; then + # Some make implementations, like *BSD's, pass the recipes to the shell + # through its standard input. Trying to run our extra checks in this + # case would be too tricky, so we just skip them. + exec $am__SHELL $am__shell_flags ${1+"$@"} +else + am__tweaked_shell_command=`printf '%s\n' "$am__shell_command" \ + | tr -d " $tab$nl"` + case ${am__tweaked_shell_command-} in + *\\) + echo "my-shell: recipe ends with backslash character" >&2 + printf '%s\n' "=== BEGIN recipe" >&2 + printf '%s\n' "${am__shell_command-}" >&2 + printf '%s\n' "=== END recipe" >&2 + exit 99 + ;; + esac + exec $am__SHELL $am__shell_flags -c "$am__shell_command" ${1+"$@"} +fi +END +chmod a+x my-shell + +cat my-shell + +CONFIG_SHELL=`pwd`/my-shell; export CONFIG_SHELL + +$ACLOCAL +$AUTOCONF +$AUTOMAKE -a + +./configure CONFIG_SHELL="$CONFIG_SHELL" + +# Sanity check. +st=0 +$MAKE bad-recipe 2>stderr && st=1 +cat stderr >&2 +$FGREP "my-shell: recipe ends with backslash character" stderr || st=1 +test $st -eq 0 || skip_ "can't catch trailing backslashes in make recipes" + +$MAKE check + +: -- 1.7.7.3 --------------010908040805020807010504-- From debbugs-submit-bounces@debbugs.gnu.org Thu Jan 05 08:12:19 2012 Received: (at 10436) by debbugs.gnu.org; 5 Jan 2012 13:12:20 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Rin7D-0001LL-CZ for submit@debbugs.gnu.org; Thu, 05 Jan 2012 08:12:19 -0500 Received: from mail-we0-f172.google.com ([74.125.82.172]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Rin7A-0001L6-71; Thu, 05 Jan 2012 08:12:17 -0500 Received: by werb14 with SMTP id b14so360758wer.3 for ; Thu, 05 Jan 2012 05:08:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; bh=ccoaJI1LvPmRE/zI0cSnkmvzikIkg0yqZJnoGywQPVM=; b=YiqB0ZdHDmX/uPOS7jMiX5Pc+BaevnS01bc6DhjyQF9yYCQfhww5+EPTs0IezWykI9 PtrTKrHXbvK/v9lRDn6BreIOS34hEFbDNH7DlpMmeKZfIwFPVr4oDjDtS4H72x0jwOX8 R1NOboMqQt3ZpVgBAV2kUzA2PPEga00ayPrtU= Received: by 10.216.139.25 with SMTP id b25mr1137508wej.41.1325768924338; Thu, 05 Jan 2012 05:08:44 -0800 (PST) Received: from [82.54.101.15] (host15-101-dynamic.54-82-r.retail.telecomitalia.it. [82.54.101.15]) by mx.google.com with ESMTPS id fi6sm134650626wib.2.2012.01.05.05.08.43 (version=SSLv3 cipher=OTHER); Thu, 05 Jan 2012 05:08:43 -0800 (PST) Message-ID: <4F05A0D9.10401@gmail.com> Date: Thu, 05 Jan 2012 14:08:41 +0100 From: Stefano Lattarini MIME-Version: 1.0 To: Paul Eggert Subject: Re: bug#10436: New testsuite driver and extra trailing backslash in recipes References: <87aa64k902.fsf@rho.meyering.net> <4F033BB0.4090305@gmail.com> <4F0566B3.2030104@cs.ucla.edu> <4F059BE8.6000107@gmail.com> In-Reply-To: <4F059BE8.6000107@gmail.com> Content-Type: multipart/mixed; boundary="------------070402030302000509070705" X-Spam-Score: -4.1 (----) X-Debbugs-Envelope-To: 10436 Cc: 10436@debbugs.gnu.org, automake-patches@gnu.org, 10427@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.1 (----) This is a multi-part message in MIME format. --------------070402030302000509070705 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 01/05/2012 01:47 PM, Stefano Lattarini wrote: > [adding bug-automake in CC:] > > Reference: > And here is the definitive version of the patch that I'll push by this evening (to master) if there is no objection. Thanks, Stefano --------------070402030302000509070705 Content-Type: text/x-diff; name="0001-parallel-tests-avoid-trailing-backslashes-in-make-re.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-parallel-tests-avoid-trailing-backslashes-in-make-re.pa"; filename*1="tch" >From c891eff22b84027ea56cf67b4c5aac55b75390d9 Mon Sep 17 00:00:00 2001 Message-Id: From: Stefano Lattarini Date: Thu, 5 Jan 2012 13:41:13 +0100 Subject: [PATCH] parallel-tests: avoid trailing backslashes in make recipes The new testsuite-harness could generate recipes with a trailing backslash character (possibly followed by blank characters only), in the very common case where the user hadn't defined the special $(AM_TESTS_FD_REDIRECT) variable. This caused spurious syntax errors with at least older bash versions (e.g., bash 2.05b), and could be potentially unportable to other weaker shells. See automake bug#10436: and coreutils bug#10427: * lib/am/check2.am: Rework line breaks so that no backslash can be at the end of a line. * tests/parallel-tests-trailing-bslash.test: New test. * tests/list-of-tests.mk: Add it. --- lib/am/check2.am | 10 +- tests/list-of-tests.mk | 1 + tests/parallel-tests-trailing-bslash.test | 114 +++++++++++++++++++++++++++++ 3 files changed, 120 insertions(+), 5 deletions(-) create mode 100755 tests/parallel-tests-trailing-bslash.test diff --git a/lib/am/check2.am b/lib/am/check2.am index ad0a4aa..9a0fe9d 100644 --- a/lib/am/check2.am +++ b/lib/am/check2.am @@ -1,5 +1,5 @@ ## automake - create Makefile.in from Makefile.am -## Copyright (C) 2008, 2009, 2011 Free Software Foundation, Inc. +## Copyright (C) 2008, 2009, 2011, 2012 Free Software Foundation, Inc. ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -19,8 +19,8 @@ ?!GENERIC?%OBJ%: %SOURCE% @p='%SOURCE%'; $(am__check_pre) %DRIVER% --test-name "$$f" \ --log-file '%BASE%.log' --trs-file '%BASE%.trs' \ - $(am__common_driver_flags) %DRIVER_FLAGS% -- %COMPILE% "$$tst" \ - $(AM_TESTS_FD_REDIRECT) + $(am__common_driver_flags) %DRIVER_FLAGS% -- %COMPILE% \ + "$$tst" $(AM_TESTS_FD_REDIRECT) ## If no programs are built in this package, then this rule is removed ## at automake time. Otherwise, %am__EXEEXT% expands to a configure time @@ -30,6 +30,6 @@ if %am__EXEEXT% ?GENERIC?%EXT%$(EXEEXT).log: @p='%SOURCE%'; $(am__check_pre) %DRIVER% --test-name "$$f" \ --log-file '%BASE%.log' --trs-file '%BASE%.trs' \ - $(am__common_driver_flags) %DRIVER_FLAGS% -- %COMPILE% "$$tst" \ - $(AM_TESTS_FD_REDIRECT) + $(am__common_driver_flags) %DRIVER_FLAGS% -- %COMPILE% \ + "$$tst" $(AM_TESTS_FD_REDIRECT) endif %am__EXEEXT% diff --git a/tests/list-of-tests.mk b/tests/list-of-tests.mk index 8b4f2ca..dbadfdc 100644 --- a/tests/list-of-tests.mk +++ b/tests/list-of-tests.mk @@ -709,6 +709,7 @@ parallel-tests-no-spurious-summary.test \ parallel-tests-exit-statuses.test \ parallel-tests-console-output.test \ parallel-tests-once.test \ +parallel-tests-trailing-bslash.test \ tests-environment.test \ am-tests-environment.test \ tests-environment-backcompat.test \ diff --git a/tests/parallel-tests-trailing-bslash.test b/tests/parallel-tests-trailing-bslash.test new file mode 100755 index 0000000..418b722 --- /dev/null +++ b/tests/parallel-tests-trailing-bslash.test @@ -0,0 +1,114 @@ +#! /bin/sh +# Copyright (C) 2012 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Check that the new testsuite harness do not generate recipes that can +# have a trailing `\', since that can cause spurious syntax errors with +# older bash versions (e.g., bash 2.05b). +# See automake bug#10436. + +am_parallel_tests=yes +. ./defs || Exit 1 + +echo AC_OUTPUT >> configure.in + +cat > Makefile.am <<'END' +TESTS = foo.test +EXTRA_DIST = $(TESTS) +am__backslash = \\ # foo +.PHONY: bad-recipe +bad-recipe: + @printf '%s\n' $(am__backslash) +END + +cat > foo.test <<'END' +#!/bin/sh +exit 0 +END +chmod +x foo.test + +am__SHELL=$SHELL; export am__SHELL +am__PERL=$PERL; export am__PERL + +cat > my-shell <<'END' +#!/bin/sh -e +set -u +tab=' ' +nl=' +' +am__shell_flags= +am__shell_command=; unset am__shell_command +while test $# -gt 0; do + case $1 in + # If the shell is invoked by make e.g. as "sh -ec" (seen on + # GNU make in POSIX mode) or "sh -ce" (seen on Solaris make). + -*c*) + flg=`echo x"$1" | sed -e 's/^x-//' -e 's/c//g'` + if test x"$flg" != x; then + am__shell_flags="$am__shell_flags -$flg" + fi + am__shell_command=$2 + shift + ;; + -?*) + am__shell_flags="$am__shell_flags $1" + ;; + *) + break + ;; + esac + shift +done +if test x${am__shell_command+"set"} != x"set"; then + # Some make implementations, like *BSD's, pass the recipes to the shell + # through its standard input. Trying to run our extra checks in this + # case would be too tricky, so we just skip them. + exec $am__SHELL $am__shell_flags ${1+"$@"} +else + am__tweaked_shell_command=`printf '%s\n' "$am__shell_command" \ + | tr -d " $tab$nl"` + case ${am__tweaked_shell_command-} in + *\\) + echo "my-shell: recipe ends with backslash character" >&2 + printf '%s\n' "=== BEGIN recipe" >&2 + printf '%s\n' "${am__shell_command-}" >&2 + printf '%s\n' "=== END recipe" >&2 + exit 99 + ;; + esac + exec $am__SHELL $am__shell_flags -c "$am__shell_command" ${1+"$@"} +fi +END +chmod a+x my-shell + +cat my-shell + +CONFIG_SHELL=`pwd`/my-shell; export CONFIG_SHELL + +$ACLOCAL +$AUTOCONF +$AUTOMAKE -a + +./configure CONFIG_SHELL="$CONFIG_SHELL" + +st=0 +$MAKE bad-recipe 2>stderr && st=1 +cat stderr >&2 +$FGREP "my-shell: recipe ends with backslash character" stderr || st=1 +test $st -eq 0 || skip_ "can't catch trailing backslashes in make recipes" + +$MAKE check + +: -- 1.7.7.3 --------------070402030302000509070705-- From debbugs-submit-bounces@debbugs.gnu.org Thu Jan 05 15:43:20 2012 Received: (at 10436) by debbugs.gnu.org; 5 Jan 2012 20:43:20 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Riu9f-0004N5-Ev for submit@debbugs.gnu.org; Thu, 05 Jan 2012 15:43:19 -0500 Received: from smtp.cs.ucla.edu ([131.179.128.62]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Riu9a-0004Mo-8B; Thu, 05 Jan 2012 15:43:17 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 3F26839E8010; Thu, 5 Jan 2012 12:39:41 -0800 (PST) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZDAWKsQwlEeU; Thu, 5 Jan 2012 12:39:40 -0800 (PST) Received: from penguin.cs.ucla.edu (Penguin.CS.UCLA.EDU [131.179.64.200]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 23F37A60002; Thu, 5 Jan 2012 12:39:40 -0800 (PST) Message-ID: <4F060A8B.8070404@cs.ucla.edu> Date: Thu, 05 Jan 2012 12:39:39 -0800 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20111115 Thunderbird/8.0 MIME-Version: 1.0 To: Stefano Lattarini Subject: Re: bug#10427: bug#10436: New testsuite driver and extra trailing backslash in recipes References: <87aa64k902.fsf@rho.meyering.net> <4F033BB0.4090305@gmail.com> <4F0566B3.2030104@cs.ucla.edu> <4F059BE8.6000107@gmail.com> <4F05A0D9.10401@gmail.com> In-Reply-To: <4F05A0D9.10401@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Score: -3.0 (---) X-Debbugs-Envelope-To: 10436 Cc: autoconf-patches@gnu.org, 10436@debbugs.gnu.org, automake-patches@gnu.org, 10427@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.0 (---) I pushed the following doc fix into Autoconf, so that these two portability issues are documented there. It turns out that the second issue is actually due to an old Bash bug -- it's not Solaris-specific. >From b1f0e147aa7aa259dea2c34c5a0ac7965d6efd7e Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 5 Jan 2012 11:00:45 -0800 Subject: [PATCH 1/2] doc: clarify sed buffer limit * doc/autoconf.texi (Limitations of Usual Tools): That 4000-byte limit applies to output and internal buffers, too. --- ChangeLog | 6 ++++++ doc/autoconf.texi | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 30312be..238c09f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2012-01-05 Paul Eggert + + doc: clarify sed buffer limit + * doc/autoconf.texi (Limitations of Usual Tools): + That 4000-byte limit applies to output and internal buffers, too. + 2012-01-03 Paul Eggert maint: update copyright year diff --git a/doc/autoconf.texi b/doc/autoconf.texi index 72ff7f8..ea2419b 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -19256,8 +19256,9 @@ $ @kbd{echo a | sed 's/x/x/;;s/x/x/'} sed: 1: "s/x/x/;;s/x/x/": invalid command code ; @end example -Input should not have unreasonably long lines, since some @command{sed} -implementations have an input buffer limited to 4000 bytes. Likewise, +Some @command{sed} implementations have a buffer limited to 4000 bytes, +and this limits the size of input lines, output lines, and internal +buffers that can be processed portably. Likewise, not all @command{sed} implementations can handle embedded @code{NUL} or a missing trailing newline. -- 1.7.6.5 >From 0445b4ad121e6356f409833dec3678ae613e1d08 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 5 Jan 2012 12:32:12 -0800 Subject: [PATCH 2/2] doc: mention Bash 2.03 bug with backslash-newline * doc/autoconf.texi (Invoking the Shell): New section. (Backslash-Newline-Empty): Rename from Backslash-Newline-Newline. Mention problem with Bash 2.03. --- ChangeLog | 5 ++++ doc/autoconf.texi | 56 +++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 57 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 238c09f..69df405 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2012-01-05 Paul Eggert + doc: mention Bash 2.03 bug with backslash-newline + * doc/autoconf.texi (Invoking the Shell): New section. + (Backslash-Newline-Empty): Rename from Backslash-Newline-Newline. + Mention problem with Bash 2.03. + doc: clarify sed buffer limit * doc/autoconf.texi (Limitations of Usual Tools): That 4000-byte limit applies to output and internal buffers, too. diff --git a/doc/autoconf.texi b/doc/autoconf.texi index ea2419b..5c3feef 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -501,6 +501,7 @@ Dependencies Between Macros Portable Shell Programming * Shellology:: A zoology of shells +* Invoking the Shell:: Invoking the shell as a command * Here-Documents:: Quirks and tricks * File Descriptors:: FDs and redirections * Signal Handling:: Shells, signals, and headaches @@ -520,7 +521,7 @@ Portable Make Programming * $< in Ordinary Make Rules:: $< in ordinary rules * Failure in Make Rules:: Failing portably in rules * Special Chars in Names:: Special Characters in Macro Names -* Backslash-Newline-Newline:: Empty last lines in macro definitions +* Backslash-Newline-Empty:: Empty lines after backslash-newline * Backslash-Newline Comments:: Spanning comments across line boundaries * Long Lines in Makefiles:: Line length limitations * Macros and Submakes:: @code{make macro=value} and submakes @@ -15067,6 +15068,7 @@ subset described above, is fairly portable nowadays. Also please see @menu * Shellology:: A zoology of shells +* Invoking the Shell:: Invoking the shell as a command * Here-Documents:: Quirks and tricks * File Descriptors:: FDs and redirections * Signal Handling:: Shells, signals, and headaches @@ -15205,6 +15207,28 @@ The default Mac OS X @command{sh} was originally Zsh; it was changed to Bash in Mac OS X 10.2. @end table +@node Invoking the Shell +@section Invoking the Shell +@cindex invoking the shell +@cindex shell invocation + +Bash 2.03 has a bug when invoked with the @option{-c} option: if the +option-argument ends in backslash-newline, Bash incorrectly reports a +syntax error. The problem does not occur if a character follows the +backslash: + +@example +$ @kbd{$ bash -c 'echo foo \} +> @kbd{'} +bash: -c: line 2: syntax error: unexpected end of file +$ @kbd{bash -c 'echo foo \} +> @kbd{ '} +foo +@end example + +@noindent +@xref{Backslash-Newline-Empty}, for how this can cause problems in makefiles. + @node Here-Documents @section Here-Documents @cindex Here-documents @@ -19663,7 +19687,7 @@ itself. * $< in Ordinary Make Rules:: $< in ordinary rules * Failure in Make Rules:: Failing portably in rules * Special Chars in Names:: Special Characters in Macro Names -* Backslash-Newline-Newline:: Empty last lines in macro definitions +* Backslash-Newline-Empty:: Empty lines after backslash-newline * Backslash-Newline Comments:: Spanning comments across line boundaries * Long Lines in Makefiles:: Line length limitations * Macros and Submakes:: @code{make macro=value} and submakes @@ -19741,8 +19765,32 @@ this is test @noindent However, this problem is no longer of practical concern. -@node Backslash-Newline-Newline -@section Backslash-Newline-Newline in Make Macro Values +@node Backslash-Newline-Empty +@section Backslash-Newline Before Empty Lines + +A bug in Bash 2.03 can cause problems if a Make rule contains a +backslash-newline followed by line that expands to nothing. +For example, on Solaris 8: + +@example +SHELL = /bin/bash +EMPTY = +foo: + touch foo \ + $(EMPTY) +@end example + +@noindent +executes + +@example +/bin/bash -c 'touch foo \ +' +@end example + +@noindent +which fails with a syntax error, due to the Bash bug. To avoid this +problem, avoid nullable macros in the last line of a multiline command. @c This has been seen on ia64 hpux 11.20, and on one hppa hpux 10.20, @c but another hppa hpux 10.20 didn't have it. Bob Proulx -- 1.7.6.5 From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 06 05:01:44 2012 Received: (at 10436) by debbugs.gnu.org; 6 Jan 2012 10:01:44 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Rj6cK-0007XR-Bo for submit@debbugs.gnu.org; Fri, 06 Jan 2012 05:01:44 -0500 Received: from mail-ww0-f42.google.com ([74.125.82.42]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Rj6cH-0007XE-CX; Fri, 06 Jan 2012 05:01:42 -0500 Received: by wgbds13 with SMTP id ds13so1454679wgb.3 for ; Fri, 06 Jan 2012 01:58:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=XU3/Ki5b27yNySlHbh6aTXXa/MYmyzS1XLwJhVBN53g=; b=iqC68FWA7wtHnAwjE0WGVAIdap1QInZycoZsVkSHYsXObkFzc+p290TEFLPvlR2xOs GXU67+XcKxGtgUye8tyqACCIxuDAjVV6lqzyByBxYgGXx0DGIyXPPw0W7T65DnnGouoH bLiTDvq1NTclDMQ14ph7aM5nplFDnqAmDqPs4= Received: by 10.181.12.106 with SMTP id ep10mr7365218wid.3.1325843885567; Fri, 06 Jan 2012 01:58:05 -0800 (PST) Received: from [87.0.103.105] (host105-103-dynamic.0-87-r.retail.telecomitalia.it. [87.0.103.105]) by mx.google.com with ESMTPS id 28sm67688495wby.3.2012.01.06.01.58.04 (version=SSLv3 cipher=OTHER); Fri, 06 Jan 2012 01:58:05 -0800 (PST) Message-ID: <4F06C5A5.20706@gmail.com> Date: Fri, 06 Jan 2012 10:57:57 +0100 From: Stefano Lattarini MIME-Version: 1.0 To: Paul Eggert Subject: Re: bug#10436: New testsuite driver and extra trailing backslash in recipes References: <87aa64k902.fsf@rho.meyering.net> <4F033BB0.4090305@gmail.com> <4F0566B3.2030104@cs.ucla.edu> <4F059BE8.6000107@gmail.com> <4F05A0D9.10401@gmail.com> In-Reply-To: <4F05A0D9.10401@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Score: -3.9 (---) X-Debbugs-Envelope-To: 10436 Cc: 10436@debbugs.gnu.org, automake-patches@gnu.org, 10427@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.8 (---) On 01/05/2012 02:08 PM, Stefano Lattarini wrote: > On 01/05/2012 01:47 PM, Stefano Lattarini wrote: >> [adding bug-automake in CC:] >> >> Reference: >> > And here is the definitive version of the patch that I'll push by this > evening (to master) if there is no objection. > Pushed now. Regards, Stefano From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 06 05:05:20 2012 Received: (at control) by debbugs.gnu.org; 6 Jan 2012 10:05:20 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Rj6fo-0007df-7C for submit@debbugs.gnu.org; Fri, 06 Jan 2012 05:05:20 -0500 Received: from mail-we0-f172.google.com ([74.125.82.172]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Rj6fn-0007dZ-Et for control@debbugs.gnu.org; Fri, 06 Jan 2012 05:05:19 -0500 Received: by werb14 with SMTP id b14so1070840wer.3 for ; Fri, 06 Jan 2012 02:01:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:mime-version:to:subject:content-type :content-transfer-encoding; bh=XmSFFCkRROSwJLRrNUXMtw8cmu/Vof/Jao+pePL1vm8=; b=TTGyErVRnioAaLttrpr8aVZ+66R7Sdu20UR16VIWCVRiOZp32DckBjmWgv+9c4Q80p jWrxWfxi11siMhxX2t+rZvp1cWlv4dLFnYjV/7gOQoCqTIbDWV3OPgIy2cvbSdfsy+6c 8jimntJ86YFeY7FmdlmevbD/w4QJejZYopbNY= Received: by 10.216.137.155 with SMTP id y27mr2776816wei.53.1325844103893; Fri, 06 Jan 2012 02:01:43 -0800 (PST) Received: from [87.0.103.105] (host105-103-dynamic.0-87-r.retail.telecomitalia.it. [87.0.103.105]) by mx.google.com with ESMTPS id fo18sm67686641wbb.12.2012.01.06.02.01.42 (version=SSLv3 cipher=OTHER); Fri, 06 Jan 2012 02:01:43 -0800 (PST) Message-ID: <4F06C685.9060803@gmail.com> Date: Fri, 06 Jan 2012 11:01:41 +0100 From: Stefano Lattarini MIME-Version: 1.0 To: control@debbugs.gnu.org Subject: x Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Score: -3.8 (---) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.8 (---) tags 10437 patch tags 10436 patch close 10436 close 10437 thanks From unknown Sat Sep 20 13:01:01 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 03 Feb 2012 12:24:03 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator