Re: cvs build prob

2004-07-27 Thread Patrick Welche
I can reproduce the

sed: 1: ""s/\*/\\\*/g"": invalid command code "

error with the minimum configure.ac which contains LT_LANG(C++)
which calls _LT_LANG_CXX_CONFIG,
which calls AC_LIBTOOL_PROG_LD_SHLIBS,
which calls AC_LIBTOOL_POSTDEP_PREDEP,
which has

  # The `*' in the case matches for architectures that use `case' in
  # $output_verbose_cmd can trigger glob expansion during the loop
  # eval without this substitution.
  output_verbose_link_cmd="`$echo \"X$output_verbose_link_cmd\" | $Xsed -e 
\"$no_glob_subst\"`"

where

# Sed substitution to avoid accidental globbing in evaled expressions
no_glob_subst='s/\*/\\\*/g'

Before output_verbose_link_cmd is "no_globbed", its value is
$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e 
"s:-lgcc -lc -lgcc::"


The great part is this is a ksh quoting problem:

= foo ==
CC=cc
SED=sed
GREP=grep
echo=echo

Xsed='sed -e s/^X//'
no_glob_subst='s/\*/\\\*/g'

output_verbose_link_cmd="$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP 
conftest.$objext | $SED -e \"s:-lgcc -lc -lgcc::\""
echo "output_cmd: ($output_verbose_link_cmd)"
output_verbose_link_cmd="`$echo \"X$output_verbose_link_cmd\" | $Xsed -e 
\"$no_glob_subst\"`"
echo "output_cmd: ($output_verbose_link_cmd)"

% sh foo
output_cmd: (cc -shared  -v conftest. 2>&1 | grep conftest. | sed -e "s:-lgcc -lc 
-lgcc::")
output_cmd: (cc -shared  -v conftest. 2>&1 | grep conftest. | sed -e "s:-lgcc -lc 
-lgcc::")
% ksh foo
output_cmd: (cc -shared  -v conftest. 2>&1 | grep conftest. | sed -e "s:-lgcc -lc 
-lgcc::")
sed: 1: ""s/\*/\\\*/g"": invalid command code "
output_cmd: ()


Oh joy... (ksh version @(#)PD KSH v5.2.14 99/07/13.2)


Cheers,

Patrick


___
Libtool mailing list
[EMAIL PROTECTED]
http://lists.gnu.org/mailman/listinfo/libtool


Re: cvs build prob

2004-07-27 Thread Patrick Welche
On Tue, Jul 27, 2004 at 04:07:14PM +0100, Patrick Welche wrote:
> The great part is this is a ksh quoting problem:
> Oh joy... (ksh version @(#)PD KSH v5.2.14 99/07/13.2)

.. and it is explained in TFM:

   The following is a list of things that are affected by the state of the
   posix option:
 o\"  inside  double  quoted  `..` command substitutions: in posix
  mode, the \" is interpreted when the command is interpreted;  in
  non-posix  mode,  the  backslash  is stripped before the command
  substitution is interpreted.  For example, echo "`echo  \"hi\"`"
  produces `"hi"' in posix mode, `hi' in non-posix mode.  To avoid
  problems, use the $(...)  form of command substitution.

So what now for the libtool point of view?

- I still wonder why ksh is chosen over sh on my NetBSD system.
- Should we "use the $(...)  form of command substitution" "To avoid problems"?

Reminder of the miscreant line:

  output_verbose_link_cmd="`$echo \"X$output_verbose_link_cmd\" | $Xsed -e 
\"$no_glob_subst\"`"

(setting set +o posix in configure for the benefit of ksh fixes things too.)

Cheers,

Patrick


___
Libtool mailing list
[EMAIL PROTECTED]
http://lists.gnu.org/mailman/listinfo/libtool


Re: cvs build prob

2004-07-27 Thread Bob Friesenhahn
There must be a syntax which works in all cases.  We have encountered 
(and fixed) this backslash problem before.

Bob
On Tue, 27 Jul 2004, Patrick Welche wrote:
On Tue, Jul 27, 2004 at 04:07:14PM +0100, Patrick Welche wrote:
The great part is this is a ksh quoting problem:
Oh joy... (ksh version @(#)PD KSH v5.2.14 99/07/13.2)
.. and it is explained in TFM:
  The following is a list of things that are affected by the state of the
  posix option:
o\"  inside  double  quoted  `..` command substitutions: in posix
 mode, the \" is interpreted when the command is interpreted;  in
 non-posix  mode,  the  backslash  is stripped before the command
 substitution is interpreted.  For example, echo "`echo  \"hi\"`"
 produces `"hi"' in posix mode, `hi' in non-posix mode.  To avoid
 problems, use the $(...)  form of command substitution.
So what now for the libtool point of view?
- I still wonder why ksh is chosen over sh on my NetBSD system.
- Should we "use the $(...)  form of command substitution" "To avoid problems"?
Reminder of the miscreant line:
 output_verbose_link_cmd="`$echo \"X$output_verbose_link_cmd\" | $Xsed -e 
\"$no_glob_subst\"`"
(setting set +o posix in configure for the benefit of ksh fixes things too.)
Cheers,
Patrick
___
Libtool mailing list
[EMAIL PROTECTED]
http://lists.gnu.org/mailman/listinfo/libtool
==
Bob Friesenhahn
[EMAIL PROTECTED]
http://www.simplesystems.org/users/bfriesen
___
Libtool mailing list
[EMAIL PROTECTED]
http://lists.gnu.org/mailman/listinfo/libtool


Re: cvs build prob

2004-07-27 Thread Alexandre Duret-Lutz
On Tue, Jul 27, 2004 at 05:15:17PM +0100, Patrick Welche wrote:

> Reminder of the miscreant line:
>
>   output_verbose_link_cmd="`$echo \"X$output_verbose_link_cmd\" | $Xsed -e 
> \"$no_glob_subst\"`"
>

Why not replacing it with

output_verbose_link_cmd=`$echo "X$output_verbose_link_cmd" | $Xsed "$no_glob_subst"`

?

The right-hand side of `=' is never IFS-splitted, so the outermost
double quotes are superfluous.


___
Libtool mailing list
[EMAIL PROTECTED]
http://lists.gnu.org/mailman/listinfo/libtool


Re: cvs build prob

2004-07-27 Thread Patrick Welche
On Tue, Jul 27, 2004 at 11:23:29AM -0500, Bob Friesenhahn wrote:
> There must be a syntax which works in all cases.  We have encountered 
> (and fixed) this backslash problem before.

Just removing the extra backslashs in that line "work for me", but I don't
know if that will work always..

Cheers,

Patrick


___
Libtool mailing list
[EMAIL PROTECTED]
http://lists.gnu.org/mailman/listinfo/libtool


Re: cvs build prob

2004-07-27 Thread Gary V. Vaughan
Alexandre Duret-Lutz wrote:
> On Tue, Jul 27, 2004 at 05:15:17PM +0100, Patrick Welche wrote:
> 
>>Reminder of the miscreant line:
>>
>>  output_verbose_link_cmd="`$echo \"X$output_verbose_link_cmd\" | $Xsed -e 
>> \"$no_glob_subst\"`"
>>
> 
> 
> Why not replacing it with
> 
> output_verbose_link_cmd=`$echo "X$output_verbose_link_cmd" | $Xsed "$no_glob_subst"`
> 
> ?
> 
> The right-hand side of `=' is never IFS-splitted, so the outermost
> double quotes are superfluous.

Indeed!  Patrick, can you confirm that this fixes it for you?  You'll probably
encounter another problem in the same area that I am working on, but you
should see a different error message at least :-(

We probably need to audit the whole of libtool for nested quotes, and add
a test case to sh.test to stop us introducing more.  Bonus marks for a patch :*)

Cheers,
Gary.
-- 
Gary V. Vaughan  ())_.  [EMAIL PROTECTED],gnu.org}
Research Scientist   ( '/   http://tkd.kicks-ass.net
GNU Hacker   / )=   http://www.gnu.org/software/libtool
Technical Author   `(_~)_   http://sources.redhat.com/autobook


signature.asc
Description: OpenPGP digital signature
___
Libtool mailing list
[EMAIL PROTECTED]
http://lists.gnu.org/mailman/listinfo/libtool


Re: cvs build prob

2004-07-27 Thread Gary V. Vaughan
Hi Patrick,

Good catch!  I'm CCing the autoconf list, as this is probably a candidate for
AS_SHELL_SANITIZE, and the comparative shellology documentation...

Patrick Welche wrote:
> On Tue, Jul 27, 2004 at 04:07:14PM +0100, Patrick Welche wrote:
> 
>>The great part is this is a ksh quoting problem:
>>Oh joy... (ksh version @(#)PD KSH v5.2.14 99/07/13.2)
> 
> 
> .. and it is explained in TFM:
> 
>The following is a list of things that are affected by the state of the
>posix option:
>  o\"  inside  double  quoted  `..` command substitutions: in posix
>   mode, the \" is interpreted when the command is interpreted;  in
>   non-posix  mode,  the  backslash  is stripped before the command
>   substitution is interpreted.  For example, echo "`echo  \"hi\"`"
>   produces `"hi"' in posix mode, `hi' in non-posix mode.  To avoid
>   problems, use the $(...)  form of command substitution.
> 
> So what now for the libtool point of view?

At least until AS_SHELL_SANITIZE handles this, libtool needs to find a workaround.

> - I still wonder why ksh is chosen over sh on my NetBSD system.

ksh has function support for one thing, and maybe $LINENO support.

> - Should we "use the $(...)  form of command substitution" "To avoid problems"?

We can't use $(...) indiscriminately, as plenty of ancient bourne compatible
shells will choke on it :-(

> Reminder of the miscreant line:
> 
>   output_verbose_link_cmd="`$echo \"X$output_verbose_link_cmd\" | $Xsed -e 
> \"$no_glob_subst\"`"
> 
> (setting set +o posix in configure for the benefit of ksh fixes things too.)

Does ksh have a way to detect itself programatically so that libtool can add
something of the form:

   test -z "$KSH_VERSION" || set +o posix

Cheers,
Gary.
-- 
Gary V. Vaughan  ())_.  [EMAIL PROTECTED],gnu.org}
Research Scientist   ( '/   http://tkd.kicks-ass.net
GNU Hacker   / )=   http://www.gnu.org/software/libtool
Technical Author   `(_~)_   http://sources.redhat.com/autobook


signature.asc
Description: OpenPGP digital signature
___
Libtool mailing list
[EMAIL PROTECTED]
http://lists.gnu.org/mailman/listinfo/libtool


Re: cvs build prob

2004-07-27 Thread Paul Eggert
"Gary V. Vaughan" <[EMAIL PROTECTED]> writes:

> Good catch!  I'm CCing the autoconf list, as this is probably a candidate for
> AS_SHELL_SANITIZE, and the comparative shellology documentation...

Thanks.  I installed the patch enclosed below.

>> Reminder of the miscreant line:
>> 
>>   output_verbose_link_cmd="`$echo \"X$output_verbose_link_cmd\" | $Xsed -e 
>> \"$no_glob_subst\"`"

The workaround in this case is easy.  Just omit the outer quotes and
remove the inner backslashes:

output_verbose_link_cmd=`$echo "X$output_verbose_link_cmd" | $Xsed -e "$no_glob_subst"`

The outer quotes aren't needed.  This issue is discussed in the
Autoconf manual's Shellology section.

Anyway, here's the Autoconf patch I installed.

2004-07-27  Paul Eggert  <[EMAIL PROTECTED]>

* lib/m4sugar/m4sh.m4 (_AS_BOURNE_COMPATIBLE): Use "set -o posix"
with pdksh, too.  Problem reported by Patrick Welche via
Gary V. Vaughan.
* doc/autoconf.texi (Shellology): Note that set -o posix is
useful for pkdsh, too.

Index: doc/autoconf.texi
===
RCS file: /cvsroot/autoconf/autoconf/doc/autoconf.texi,v
retrieving revision 1.822
diff -p -u -r1.822 autoconf.texi
--- doc/autoconf.texi   4 Jun 2004 20:40:33 -   1.822
+++ doc/autoconf.texi   27 Jul 2004 20:11:08 -
@@ -9366,8 +9366,8 @@ Substitutions}, item ``Command Substitut
 
 @item Bash
 @cindex Bash
-To detect whether you are running @command{bash}, test if
[EMAIL PROTECTED] is set.  To disable its extensions and require
+To detect whether you are running @command{bash}, test whether
[EMAIL PROTECTED] is set.  To require
 @acronym{POSIX} compatibility, run @samp{set -o posix}.  @xref{Bash POSIX
 Mode,, Bash @acronym{POSIX} Mode, bash, The @acronym{GNU} Bash Reference
 Manual}, for details.
@@ -9407,6 +9407,9 @@ not have it.
 A public-domain clone of the Korn shell called @samp{pdksh} is also
 widely available: it has most of the @samp{ksh88} features along with
 a few of its own.
+Similarly to @command{bash}, you can detect whether you are running
[EMAIL PROTECTED] by testing whether @code{KSH_VERSION} is set, and you can
+require @acronym{POSIX} compatibility by running @samp{set -o posix}.
 
 @item Zsh
 @cindex Zsh
Index: lib/m4sugar/m4sh.m4
===
RCS file: /cvsroot/autoconf/autoconf/lib/m4sugar/m4sh.m4,v
retrieving revision 1.117
diff -p -u -r1.117 m4sh.m4
--- lib/m4sugar/m4sh.m4 24 Jun 2004 15:00:30 -  1.117
+++ lib/m4sugar/m4sh.m4 27 Jul 2004 20:11:08 -
@@ -162,7 +162,7 @@ if test -n "${ZSH_VERSION+set}" && (emul
   # is contrary to our usage.  Disable this feature.
   alias -g '${1+"[EMAIL PROTECTED]"}'='"[EMAIL PROTECTED]"'
   setopt NO_GLOB_SUBST
-elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
+elif test -n "${BASH_VERSION+set}${KSH_VERSION+set}" && (set -o posix) >/dev/null 
2>&1; then
   set -o posix
 fi
 DUALCASE=1; export DUALCASE # for MKS sh


___
Libtool mailing list
[EMAIL PROTECTED]
http://lists.gnu.org/mailman/listinfo/libtool