libtool
[Top][All Lists]
Advanced

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

Re: win32 short name and IFS='~'


From: Robert Boehne
Subject: Re: win32 short name and IFS='~'
Date: Tue, 22 Apr 2003 01:24:57 -0500

Naofumi,

I tried your original patch that moved the expansions around,
but it caused problems for me.  The most delicate part of Libtool
is the quoting, if anything in the quoting changes, it's almost
certain to break something.  Quoting in Libtool has to work
the same in bash as it does on a wide variety of Bourne shells
with various bugs.
Besides, wouldn't we all rather have the IFS hack removed anyway?
There will always be some situation where someone can't use any
character that we come up with, so let's not use any of them.  ;)
Now I realize that you have spent time on fixing this, and aren't
too happy about the prospect of starting over with a different approach.
I do sympathize with that, but as I see it eliminating the setting
of IFS is the only solution that isn't just trading one problem for
another.

Thanks,

Robert

Naofumi Yasufuku wrote:
> 
> At Thu, 17 Apr 2003 14:49:45 -0500,
> Boehne, Robert wrote:
> >
> > Naofumi,
> >
> > #! /bin/sh
> > # How about ditching use of IFS totally in favor of a series of commands
> > # to be executed.  For example, we currently use
> > show="echo"
> > run=
> >
> > test_cmds='echo "do command one"~echo "do command two"~echo "do command 
> > three"'
> >
> > #then, rather than do this:
> >       save_ifs="$IFS"; IFS='~'
> >       for cmd in $test_cmds; do
> >         IFS="$save_ifs"
> >         $show "$cmd"
> >         $run eval "$cmd" || exit $?
> >       done
> >       IFS="$save_ifs"
> >
> > # suppose we used
> > archive_cmds_1='echo "do command one"'
> > archive_cmds_2='echo "do command two"'
> > archive_cmds_3='echo "do command three"'
> > archvie_cmds_max=3
> >
> > echo " We would do something like this: "
> > n=0
> > cmd=
> > while true; do
> >   n=`expr $n + 1`
> >   cmd="\$archive_cmds_$n"
> >   if test $n -le $archvie_cmds_max ; then
> >     $show "$cmd"
> >     $run eval "$cmd" || exit $?
> >   else
> >     break;
> >   fi
> > done
> >
> > The real trick to making this work is to get the
> > shell quoting exactly the same so that we can simply
> > take current command (~ separated lists) and convert them to
> > a series without changing the quoting.
> > The script above doesn't do this :(  but it can be used
> > by all to attempt to figure out the right quoting to
> > have the desired result.  This type of solution has
> > the distinct advantage of not using any other character
> > for IFS, and so cannot ever clash with characters in
> > commands.
> > I would also encourage the use of shell functions to
> > simplify this, or any other bit of libtool for that matter.
> >
> 
> Robert,
> 
> The nature of this '~'-IFS problem is when command variables should be
> expanded.
> "first expand, then separate" or "first separate, then expand".
> 
>   #! /bin/sh
>   # "first expand, then separate" (current libtool)
> 
>   archive_cmds="\$command_one \$deplibs~\$command_two"
> 
>   command_one='gcc -shared ...'
>   command_two='echo "do command two"'
> 
>   deplibs='-L/foo~bar/lib -lbaz'
> 
>   eval cmds=\"$archive_cmds\"  # *** first expand archive_cmds ***
> 
>   # Execute for earch field
>   save_ifs="$IFS"; IFS='~'
>   for cmd in $cmds; do         # *** then separate ***
>     IFS="$save_ifs"
>     $show "$cmd"
>     $run eval "$cmd" || exit $?
>   done
>   IFS="$save_ifs"
> 
> $cmds will be separated at wrong point (-L/foo; bar/lib -lbaz).
> 
>   #! /bin/sh
>   # "first separate, then expand"
> 
>   archive_cmds="\$command_one \$deplibs~\$command_two"
> 
>   command_one='gcc -shared ...'
>   command_two='echo "do command two"'
> 
>   deplibs='-L/foo~bar/lib -lbaz'
> 
>   # Execute for earch field
>   save_ifs="$IFS"; IFS='~'
>   for cmd in $archive_cmds; do  # *** first separate ***
>     IFS="$save_ifs"
>     eval cmd=\"$cmd\"           # *** then expand cmd ***
>     $show "$cmd"
>     $run eval "$cmd" || exit $?
>   done
>   IFS="$save_ifs"
> 
> This is the solution that I suggested first. $archive_cmds will be
> separated at right point. We don't need to be concerned about '~' in
> $archive_cmds.
> 
>   #! /bin/sh
>   # The solution Robert suggested
> 
>   archive_cmds="\$command_one \$deplibs~\$command_two"
> 
>   command_one='gcc -shared ...'
>   command_two='echo "do command two"'
> 
>   deplibs='-L/foo~bar/lib -lbaz'
> 
>   # *** Expand archive_cmds ***
>   eval cmds=\"$archive_cmds\"
> 
>   # Convert to a series (will fail :-<)
>   archive_cmds_1='gcc -shared ... -L/foo'
>   archive_cmds_2='bar/lib -lbaz'
>   archive_cmds_3='echo "do command two"'
>   archvie_cmds_max=3
> 
>   n=0
>   cmd=
>   while true; do
>     n=`expr $n + 1`
>     cmd="\$archive_cmds_$n"
>     if test $n -le $archvie_cmds_max ; then
>       $show "$cmd"
>       $run eval "$cmd" || exit $?
>     else
>       break;
>     fi
>   done
> 
> It will be the same result of current libtool.
> 
> Regards,
> --Naofumi
> 
> _______________________________________________
> Libtool mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/libtool




reply via email to

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