bug-libtool
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

backslashes in darwin archive_cmds


From: Robby Griffin
Subject: backslashes in darwin archive_cmds
Date: Thu, 04 Jan 2001 04:35:22 -0500

I'm working with a fairly plain installation of MacOS X Public Beta, which
means /bin/sh is zsh 3.0.6 and config.guess returns "powerpc-apple-darwin1.2".
I just checked out the HEAD revision of libtool (claims to be
"libtool 1.3c (1.849 2000/12/23 16:30:42)") and saw this during 'make':

/bin/sh ./libtool --mode=compile cc -DHAVE_CONFIG_H -I. -I. -I.     -g -O2 -c 
ltdl.c
./libtool: parse error near `fi\' [-1]
./libtool: parse error in command substitution [185]
./libtool: parse error near `fi\' [-1]
./libtool: parse error in command substitution [187]

Lines 185 and 187 in libtool appear to have even numbers of consecutive
backslashes where there probably ought to be odd numbers:

# head -187 libtool | tail -5
# Commands used to build and install a shared archive.
archive_cmds="\$CC \\`if test \\"\$module\\" = \\"yes\\"; then echo -bundle; 
else
      echo -dynamiclib; fi\\` -o \$lib \$libobjs \$deplibs \$linkopts"
archive_expsym_cmds="\$CC \\`if test \\"\$module\\" = \\"yes\\"; then echo 
-bundle; else
      echo -dynamiclib; fi\\` -o \$lib \$libobjs \$deplibs \$linkopts && strip 
-s \$export_symbols"

I believe this code is getting broken by the fact that sh is zsh, which
probably makes this technically a zsh or MacOS bug. It does odd things when
substituting strings that contain backslashes into expressions outside
of double quotes:

# /bin/sh
# foo='foo\\bar'
# echo "$foo"
foo\\bar                 (as expected)
# echo $foo
foo\bar                  (missing a backslash)
# echo `echo "$foo"`
foo\bar                  (missing a backslash)
# echo "`echo \"$foo\"`"
foo\\bar                 (as expected)

So an approximate answer seems to be to add double quotes around any
expressions that may need to return strings containing backslashes. Ick.
Patch below avoids the parse errors above, hopefully without breaking
anything else...

        --Robby

Index: libtool.m4
===================================================================
RCS file: /home/cvs/libtool/libtool.m4,v
retrieving revision 1.141
diff -u -5 -r1.141 libtool.m4
--- libtool.m4  2000/12/22 23:40:11     1.141
+++ libtool.m4  2001/01/04 09:20:52
@@ -2176,14 +2176,14 @@
     export_symbols_cmds | archive_cmds | archive_expsym_cmds | \
     extract_expsyms_cmds | old_archive_from_expsyms_cmds | \
     postinstall_cmds | postuninstall_cmds | \
     finish_cmds | sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
       # Double-quote double-evaled strings.
-      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e 
\"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e 
\"\$delay_variable_subst\"\`\\\""
+      eval "lt_$var=\"\\\"\`\$echo \\\"X\$$var\\\" | \$Xsed -e 
\\\"\$double_quote_subst\\\" -e \\\"\\\$sed_quote_subst\\\" -e 
\\\"\$delay_variable_subst\\\"\`\\\"\""
       ;;
     *)
-      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e 
\"\$sed_quote_subst\"\`\\\""
+      eval "lt_$var=\"\\\"\`\$echo \\\"X\$$var\\\" | \$Xsed -e 
\\\"\$sed_quote_subst\\\"\`\\\"\""
       ;;
     esac
   done
 
   cat <<__EOF__ > "${ofile}T"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]