Re: [HACKERS] Problems with src/pl/tcl/mkMakefile.tcldefs.sh.in in 6.5
| От | |
|---|---|
| Тема | Re: [HACKERS] Problems with src/pl/tcl/mkMakefile.tcldefs.sh.in in 6.5 |
| Дата | |
| Msg-id | 9e1f9d2231fe5a4c1c4a5c81165c4211 обсуждение |
| Ответ на | Re: [HACKERS] Problems with src/pl/tcl/mkMakefile.tcldefs.sh.in in 6.5 (Bruce Momjian <maillist@candle.pha.pa.us>) |
| Список | pgsql-hackers |
On Sat, Jul 10, 1999 at 11:37:24AM -0400, Tom Lane wrote:
> Bruce Momjian <maillist@candle.pha.pa.us> writes:
> > I understand what your patch does, and it looks OK, but any idea why the
> > 'eval eval' was there, and is it safe to skip it?
>
> I think the idea is to expand any shell variable references that appear
> in tclConfig.sh. If so, the code is wrong anyway, since the expansion
> will occur in a subshell that hasn't actually executed tclConfig.sh,
> and therefore does not have definitions for the referenced variables.
> We'll always get empty strings substituted for the references, and that
> may be the wrong thing.
>
> Taking an example that actually appears in my system's tclConfig.sh:
> TCL_LIB_FILE='libtcl8.0${TCL_DBGX}.a'
>
> I stick this into shell variable inp:
>
> $ read inp
> TCL_LIB_FILE='libtcl8.0${TCL_DBGX}.a' --- typed by me
> $ echo $inp
> TCL_LIB_FILE='libtcl8.0${TCL_DBGX}.a'
>
> Now one eval gets rid of the outer single quotes:
>
> $ eval echo $inp
> TCL_LIB_FILE=libtcl8.0${TCL_DBGX}.a
>
> and another one will perform a round of shell interpretation on what's
> inside the quotes:
>
> $ eval eval echo $inp
> TCL_LIB_FILE=libtcl8.0.a
>
> which is not what we want. In this particular case it's harmless
> because TCL_DBGX should be empty, but if I had a debugging build
> of Tcl installed here then the makefile would fail because it would
> have the wrong value of TCL_LIB_FILE.
>
> If we do something like what Albert is proposing, the sed script
> will need to convert ${...} to $(...) so that shell variable references
> become make variable references.
Ok, try the following patch:
--- src/pl/tcl/mkMakefile.tcldefs.sh.in.orig Sat Jul 10 14:09:52 1999
+++ src/pl/tcl/mkMakefile.tcldefs.sh.in Sat Jul 10 14:15:50 1999
@@ -6,11 +6,11 @@ exit 1fi
+# Strip outer quotes from variable and expand ${VAR} to $(VAR) for
+# interpretation by makecat @TCL_CONFIG_SH@ | egrep '^TCL_|^TK_' |
- while read inp
- do
- eval eval echo $inp
- done >Makefile.tcldefs
+ sed -e "s/^\([^=]*\)='\(.*\)'$/\1=\2/g" \
+ -e 's/\${\([^}][^}]*\)}/$(\1)/g' >Makefile.tcldefsexit 0
> regards, tom lane
Thanks Tom!
--
albert chin (china@thewrittenword.com)
В списке pgsql-hackers по дате отправления: