[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: sed: portability of $ in pattern (Was: Re: [PATCH] Speedup creation
From: |
Paul Eggert |
Subject: |
Re: sed: portability of $ in pattern (Was: Re: [PATCH] Speedup creation of configure.lineno) |
Date: |
07 Jan 2004 16:00:47 -0800 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 |
Alexandre Duret-Lutz <address@hidden> writes:
> ac_i=`echo "$ac_i" |
> sed 's/\$U\././;s/\.o$//;s/\.obj$//'`
>
> Inside back-quotes, \ is active only before $ and `,
> so the command actually run in the sub-shell is
>
> echo "$ac_i" | sed 's/$U\././;s/\.o$//;s/\.obj$//'
>
> Note the $U which ought to be a [$]U.
Aack. This is a confusing area, and I suspect (without being able to
prove it) that we can't rely on POSIX semantics here. I installed
this patch, which uses my usual workaround for this sort of problem.
2004-01-07 Paul Eggert <address@hidden>
* lib/autoconf/general.m4 (_AC_LIBOBJS_NORMALIZE): Avoid \$ inside
`"'...'"`, as it's confusing (and I suspect it may not work on
some platforms). The code was incorrect anyway, as it assumed
that \$ evaluated to itself in that context. Reported by
Alexandre Duret-Lutz.
--- general.m4.~1.826.~ Sun Jan 4 22:19:09 2004
+++ general.m4 Wed Jan 7 15:46:43 2004
@@ -2445,8 +2445,8 @@ AC_DEFUN([_AC_LIBOBJS_NORMALIZE],
ac_ltlibobjs=
for ac_i in : $LIB@&address@hidden; do test "x$ac_i" = x: && continue
# 1. Remove the extension, and $U if already installed.
- ac_i=`echo "$ac_i" |
- sed 's/\$U\././;s/\.o$//;s/\.obj$//'`
+ ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
+ ac_i=`echo "$ac_i" | sed "$ac_script"`
# 2. Add them.
ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext"
ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo'
> >>> "Paul" == Paul Eggert <address@hidden> writes:
> >> + /$LINENO/=' <$as_myself |
>
> Paul> For portability the $ needs to be escaped from 'sed' by
> Paul> surrounding it with square brackets, which in turn need
> Paul> to be doubled, thus: [[$]]LINENO.
>
> Any idea where it does not work?
Sorry, no.