On Fri, Oct 05, 2001 at 06:22:43PM -0700, Paul Eggert wrote: > > From: "Gary V. Vaughan" <[EMAIL PROTECTED]> > > Date: Fri, 5 Oct 2001 22:46:36 +0100 > > > > libtool needs to store lots of script snippets in shell variables to > > be passed to eval later. In order for this to work, it must be > > possible to backslash escape shell meta characters, so that eval's > > behaviour is predictable. > > In this case I don't think it's feasible to require a POSIX shell on > the part of the installer, as you probably still want to run on bare > SunOS 4.1.4. So it's a somewhat different case from LINENO, which > isn't needed for correct operation of "configure". > > That being said, have you tried doing something like this as a replacement > for escaped_something=`echo "$something" | sed 's/\\/\\\\/g'`? > > case $something in > *\\*) > awk_script='{ > input=$0 > output="" > while ((i = index(input, "\\")) != 0) { > output = output substr(input, 1, i) "\\" > input = substr(input, i + 1) > } > print output input > }' > escaped_something=`awk "$awk_script" <<EOF > $something > EOF > ` > ;; > *) > escaped_something=$something;; > esac
No, I haven't tried this sort of thing. But I am willing to experiment on the HEAD branch. Unfortunately, my hacking time is much reduced for the next month or three so I am barely managing to keep up with patch submissions. > This is a bit hard to read, but it is quite portable and you can > package it up into an Autoconf macro. And in the common case where > $something contains no backslashes, this solution runs about 50 times > faster than the echo|sed solution (at least, on my Solaris 8 box). > > Maybe something like this should be added to Autoconf. Certainly > Autoconf is now buggy in more than one place, if "configure" is passed > operands that contain backslashes. I think this is certainly worth a try. If it works out, we would then be in a position to think about reexecing with a shell that supports functions (cf. my other mail in this thread), and configure scripts could be a whole lot shorter! Cheers, Gary. -- ())_. Gary V. Vaughan gary@(oranda.demon.co.uk|gnu.org) ( '/ Research Scientist http://www.oranda.demon.co.uk ,_())____ / )= GNU Hacker http://www.gnu.org/software/libtool \' `& `(_~)_ Tech' Author http://sources.redhat.com/autobook =`---d__/ _______________________________________________ Libtool mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/libtool