[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Portable use of "{", ";", etc. within sed scripts (in Automake)
From: |
Paul Eggert |
Subject: |
Portable use of "{", ";", etc. within sed scripts (in Automake) |
Date: |
Thu, 05 Jan 2006 13:55:29 -0800 |
User-agent: |
Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux) |
I looked for instances of the problem in Automake and found these.
Most likely I missed some. Also, I haven't tested this, alas.
2006-01-05 Paul Eggert <address@hidden>
* lib/install-sh (dstdir): Don't use semicolons inside { } in
sed scripts, as Posix says it's not portable.
* lib/missing (file): Likewise.
* lib/am/distdir.am (distcheck): Likewise.
* tests/comment7.test, tests/comment9.test, tests/confh.test: Likewise
* tests/distcom2.test, tests/distcom3.test: Likewise.
* tests/distcom4.test, tests/distcom5.test: Likewise.
* tests/distcom6.test, tests/include.test, tests/pluseq8.test: Likewise.
Index: lib/install-sh
===================================================================
RCS file: /cvs/automake/automake/lib/install-sh,v
retrieving revision 1.28
diff -p -u -r1.28 install-sh
--- lib/install-sh 8 Nov 2005 07:51:13 -0000 1.28
+++ lib/install-sh 5 Jan 2006 21:54:27 -0000
@@ -233,11 +233,23 @@ do
X"$dst" : 'X\(/\)' \| \
. : '\(.\)' 2>/dev/null ||
echo X"$dst" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
- /^X\(\/\/\)[^/].*/{ s//\1/; q; }
- /^X\(\/\/\)$/{ s//\1/; q; }
- /^X\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'
`
test -d "$dstdir"
Index: lib/missing
===================================================================
RCS file: /cvs/automake/automake/lib/missing,v
retrieving revision 1.29
diff -p -u -r1.29 missing
--- lib/missing 8 Jun 2005 19:41:24 -0000 1.29
+++ lib/missing 5 Jan 2006 21:54:27 -0000
@@ -3,7 +3,7 @@
scriptversion=2005-06-08.21
-# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005
+# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006
# Free Software Foundation, Inc.
# Originally by Fran,cois Pinard <address@hidden>, 1996.
@@ -293,7 +293,12 @@ WARNING: \`$1' is $msg. You should only
if test -z "$file"; then
# ... or it is the one specified with @setfilename ...
infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
- file=`sed -n '/address@hidden/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile`
+ file=`sed -n '
+ /address@hidden/{
+ s/.* \([^ ]*\) *$/\1/
+ p
+ q
+ }' $infile`
# ... or it is derived from the source name (dir/f.texi becomes f.info)
test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
fi
Index: lib/am/distdir.am
===================================================================
RCS file: /cvs/automake/automake/lib/am/distdir.am,v
retrieving revision 1.62
diff -p -u -r1.62 distdir.am
--- lib/am/distdir.am 3 Oct 2005 20:48:59 -0000 1.62
+++ lib/am/distdir.am 5 Jan 2006 21:54:27 -0000
@@ -1,5 +1,6 @@
## automake - create Makefile.in from Makefile.am
-## Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+## Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 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
@@ -381,7 +382,7 @@ distcheck: dist
$(am__remove_distdir)
@(echo "$(distdir) archives ready for distribution: "; \
list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
- sed -e '1{h;s/./=/g;p;x;}' -e '$${p;x;}'
+ sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
## Define distuninstallcheck_listfiles and distuninstallcheck separately
## from distcheck, so that they can be overridden by the user.
Index: tests/comment7.test
===================================================================
RCS file: /cvs/automake/automake/tests/comment7.test,v
retrieving revision 1.3
diff -p -u -r1.3 comment7.test
--- tests/comment7.test 14 May 2005 20:28:54 -0000 1.3
+++ tests/comment7.test 5 Jan 2006 21:54:27 -0000
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 2002 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2006 Free Software Foundation, Inc.
#
# This file is part of GNU Automake.
#
@@ -47,7 +47,13 @@ test `grep '@address@hidden' Makefile.in
test `grep '@address@hidden' Makefile.in | wc -l` = 1
# Make sure the right definition follows each comment.
-sed -n '/^#.*VAR.*COND_TRUE/ { n; p; }' Makefile.in |
+sed -n '/^#.*VAR.*COND_TRUE/ {
+ n
+ p
+ }' Makefile.in |
grep '@address@hidden = foo'
-sed -n '/^#.*VAR.*COND_FALSE/ { n; p; }' Makefile.in |
+sed -n '/^#.*VAR.*COND_FALSE/ {
+ n
+ p
+ }' Makefile.in |
grep '@address@hidden = bar'
Index: tests/comment9.test
===================================================================
RCS file: /cvs/automake/automake/tests/comment9.test,v
retrieving revision 1.3
diff -p -u -r1.3 comment9.test
--- tests/comment9.test 14 May 2005 20:28:54 -0000 1.3
+++ tests/comment9.test 5 Jan 2006 21:54:27 -0000
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 2005 Free Software Foundation, Inc.
+# Copyright (C) 2005, 2006 Free Software Foundation, Inc.
#
# This file is part of GNU Automake.
#
@@ -43,7 +43,10 @@ sed -n -e '/^TESTS =.*\\$/ {
:loop
p
n
- /\\$/ b loop
+ t clear
+ :clear
+ s/\\$/\\/
+ t loop
p
n
}' -e '/^TESTS =/ p' Makefile.in > tests
Index: tests/confh.test
===================================================================
RCS file: /cvs/automake/automake/tests/confh.test,v
retrieving revision 1.14
diff -p -u -r1.14 confh.test
--- tests/confh.test 14 May 2005 20:28:54 -0000 1.14
+++ tests/confh.test 5 Jan 2006 21:54:27 -0000
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+# Copyright (C) 1999, 2000, 2001, 2002, 2006 Free Software Foundation, Inc.
#
# This file is part of GNU Automake.
#
@@ -44,7 +44,10 @@ $AUTOMAKE || exit 1
:loop
p
n
- /\\$/ b loop
+ t clear
+ :clear
+ s/\\$/\\/
+ t loop
p
n
}' -e '/^DIST_COMMON =/ p' Makefile.in | grep acconfig.h) || exit 1
Index: tests/distcom2.test
===================================================================
RCS file: /cvs/automake/automake/tests/distcom2.test,v
retrieving revision 1.4
diff -p -u -r1.4 distcom2.test
--- tests/distcom2.test 14 May 2005 20:28:54 -0000 1.4
+++ tests/distcom2.test 5 Jan 2006 21:54:27 -0000
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc.
+# Copyright (C) 2001, 2002, 2004, 2006 Free Software Foundation, Inc.
#
# This file is part of GNU Automake.
#
@@ -55,7 +55,10 @@ sed -n -e '/^DIST_COMMON =.*\\$/ {
:loop
p
n
- /\\$/ b loop
+ t clear
+ :clear
+ s/\\$/\\/
+ t loop
p
n
}' -e '/^DIST_COMMON =/ p' Makefile.in | grep compile || exit 1
@@ -64,7 +67,10 @@ sed -n -e '/^DIST_COMMON =.*\\$/ {
:loop
p
n
- /\\$/ b loop
+ t clear
+ :clear
+ s/\\$/\\/
+ t loop
p
n
}' -e '/^DIST_COMMON =/ p' Makefile.in | grep depcomp || exit 1
Index: tests/distcom3.test
===================================================================
RCS file: /cvs/automake/automake/tests/distcom3.test,v
retrieving revision 1.4
diff -p -u -r1.4 distcom3.test
--- tests/distcom3.test 14 May 2005 20:28:54 -0000 1.4
+++ tests/distcom3.test 5 Jan 2006 21:54:27 -0000
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+# Copyright (C) 2001, 2002, 2003, 2004, 2006 Free Software Foundation, Inc.
#
# This file is part of GNU Automake.
#
@@ -46,7 +46,10 @@ sed -n -e '/^DIST_COMMON =.*\\$/ {
:loop
p
n
- /\\$/ b loop
+ t clear
+ :clear
+ s/\\$/\\/
+ t loop
p
n
}' -e '/^DIST_COMMON =/ p' Makefile.in | grep README
Index: tests/distcom4.test
===================================================================
RCS file: /cvs/automake/automake/tests/distcom4.test,v
retrieving revision 1.3
diff -p -u -r1.3 distcom4.test
--- tests/distcom4.test 14 May 2005 20:28:54 -0000 1.3
+++ tests/distcom4.test 5 Jan 2006 21:54:27 -0000
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 2003 Free Software Foundation, Inc.
+# Copyright (C) 2003, 2006 Free Software Foundation, Inc.
#
# This file is part of GNU Automake.
#
@@ -64,7 +64,10 @@ sed -n -e '/^DIST_COMMON =.*\\$/ {
:loop
p
n
- /\\$/ b loop
+ t clear
+ :clear
+ s/\\$/\\/
+ t loop
p
n
}' -e '/^DIST_COMMON =/ p' Makefile.in > dc.txt
Index: tests/distcom5.test
===================================================================
RCS file: /cvs/automake/automake/tests/distcom5.test,v
retrieving revision 1.2
diff -p -u -r1.2 distcom5.test
--- tests/distcom5.test 14 May 2005 20:28:54 -0000 1.2
+++ tests/distcom5.test 5 Jan 2006 21:54:27 -0000
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 2003 Free Software Foundation, Inc.
+# Copyright (C) 2003, 2006 Free Software Foundation, Inc.
#
# This file is part of GNU Automake.
#
@@ -65,7 +65,10 @@ sed -n -e '/^DIST_COMMON =.*\\$/ {
:loop
p
n
- /\\$/ b loop
+ t clear
+ :clear
+ s/\\$/\\/
+ t loop
p
n
}' -e '/^DIST_COMMON =/ p' Makefile.in > top.txt
@@ -74,7 +77,10 @@ sed -n -e '/^DIST_COMMON =.*\\$/ {
:loop
p
n
- /\\$/ b loop
+ t clear
+ :clear
+ s/\\$/\\/
+ t loop
p
n
}' -e '/^DIST_COMMON =/ p' tests/Makefile.in > inner.txt
Index: tests/distcom6.test
===================================================================
RCS file: /cvs/automake/automake/tests/distcom6.test,v
retrieving revision 1.3
diff -p -u -r1.3 distcom6.test
--- tests/distcom6.test 14 May 2005 20:28:54 -0000 1.3
+++ tests/distcom6.test 5 Jan 2006 21:54:27 -0000
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+# Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc.
#
# This file is part of GNU Automake.
#
@@ -60,7 +60,10 @@ sed -n -e '/^DIST_COMMON =.*\\$/ {
:loop
p
n
- /\\$/ b loop
+ t clear
+ :clear
+ s/\\$/\\/
+ t loop
p
n
}' -e '/^DIST_COMMON =/ p' Makefile.in | grep compile
@@ -69,7 +72,10 @@ sed -n -e '/^DIST_COMMON =.*\\$/ {
:loop
p
n
- /\\$/ b loop
+ t clear
+ :clear
+ s/\\$/\\/
+ t loop
p
n
}' -e '/^DIST_COMMON =/ p' Makefile.in | grep depcomp
Index: tests/include.test
===================================================================
RCS file: /cvs/automake/automake/tests/include.test,v
retrieving revision 1.7
diff -p -u -r1.7 include.test
--- tests/include.test 30 Jun 2005 11:07:41 -0000 1.7
+++ tests/include.test 5 Jan 2006 21:54:27 -0000
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 1999, 2001, 2002, 2005 Free Software Foundation, Inc.
+# Copyright (C) 1999, 2001, 2002, 2005, 2006 Free Software Foundation, Inc.
#
# This file is part of GNU Automake.
#
@@ -42,7 +42,10 @@ test $len -eq 1 || exit 1
:loop
p
n
- /\\$/ b loop
+ t clear
+ :clear
+ s/\\$/\\/
+ t loop
p
n
}' -e '/^DIST_COMMON =/ p' Makefile.in | grep foo)
Index: tests/pluseq8.test
===================================================================
RCS file: /cvs/automake/automake/tests/pluseq8.test,v
retrieving revision 1.6
diff -p -u -r1.6 pluseq8.test
--- tests/pluseq8.test 14 May 2005 20:28:55 -0000 1.6
+++ tests/pluseq8.test 5 Jan 2006 21:54:27 -0000
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 1999, 2001, 2002, 2004 Free Software Foundation, Inc.
+# Copyright (C) 1999, 2001, 2002, 2004, 2006 Free Software Foundation, Inc.
#
# This file is part of GNU Automake.
#
@@ -36,7 +36,10 @@ sed -n -e '/^VAR =/ {
:loop
p
n
- /\\$/ b loop
+ t clear
+ :clear
+ s/\\$/\\/
+ t loop
p
n
}' Makefile.in | grep three
Re: depcomp: support newer HP compilers, Alexandre Duret-Lutz, 2006/01/03