autoconf-patches
[Top][All Lists]
Advanced

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

Re: patch for problems with echo '-...' and echo '...\...'


From: Paul Eggert
Subject: Re: patch for problems with echo '-...' and echo '...\...'
Date: Sat, 25 Nov 2006 01:59:28 -0800
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

Ralf Wildenhues <address@hidden> writes:

> $ x=`perl -e 'print "x"x2060 . "\n"'`
> $ /bin/printf %s\\n $x
> Bus Error - core dumped
> $ config.guess
> sparc-sun-solaris2.7

I just now checked, and this is Sun bug 4206210, fixed in 1999.
The bug report says that there's no problem in Solaris 2.4; in 2.5 and
2.5.1 you get 'line too long', in 2.6 through 8 you get a core dump.
However, I cannot reproduce the problem in Solaris 8 sparc.

The Sun bug report claims the bug was fixed in s28_18, which I guess
was a prerelease version of Solaris 8.  If my guess is right, that'd
partly explain why it wasn't fixed in Solaris 7.

> Libtool chooses /usr/ucb/echo here, BTW.  That echo seems to work fine
> up to the maximum command line length available on the system.

OK, thanks, I installed the patch appended at the end of this message.
It should address the problem, but I have no Solaris 7 host to test it
on.  Can you please try it?

The patch doesn't use plain /usr/ucb/echo to implement AS_ECHO, since
that would mishandle AS_ECHO([-n]) (which we want to output '-n'
followed by a newline).

>> -    $(edit) `test -f ./address@hidden || echo $(srcdir)/address@hidden 
>> >address@hidden
>> +    srcdir=''; \
>> +      test -f ./address@hidden || srcdir=$(srcdir)/; \
>> +      $(edit) address@hidden >address@hidden
>>      chmod +x address@hidden
>>      chmod a-w address@hidden
>>      mv address@hidden $@
>
> This doesn't help backslashes, which I assume was the major problem spot
> here -- white space in $(srcdir) isn't possible with portable make.  But
> Automake anyway doesn't cope well with backslashes either.  OTOH, your
> change doesn't look like it would hurt much; maybe it even saves an exec.

It also saves when srcdir begins with '-', admittedly low probability.

>> -exit_missing_arg="\
>> -echo \"$as_me: option \\\`\$1' requires an argument\" >&2
>> -echo \"\$help\" >&2
>> -exit 1"
>> +exit_missing_arg='
>> +  AS_ECHO(["$as_me: option \`$[1]'\'' requires an argument"]) >&2
>> +  AS_ECHO(["$help"]) >&2
>> +  exit 1
>> +'
>
> Why do these need AS_ECHO?  More generally, what was the rationale for
> changing some but not all instances?

These use AS_ECHO since as_me and help might contain backslashes.  In
general, the idea is to use AS_ECHO when the argument might start with
"-" or might contain backslashes, and to use plain 'echo' otherwise.

>> -       echo "$usage"; exit ;;
>> +       AS_ECHO(["$usage"]); exit ;;
>
> This one will break on Solaris 2.7, when a few (3 or 4) more options
> are added to autoconf.  OTOH I don't see the necessity for it (no
> dangerous backslashes, no leading hyphen in $usage).

$usage might contain backslashes.  They aren't "dangerous" in the
sense that they won't cause core dumps or anything, but we should
do the right thing with them.  The patch should fix the Solaris 2.7
issue.

I hope this explains the other AS_ECHO instances that you thought
were superfluous and/or dangerous.

>> -    at_verbose=echo; at_quiet=:
>> +    at_verbose=; at_quiet=:
>
> Erm, using `:' aka. `true' for meaning something to be false seems to
> me rather, umm, unintuitive.  Not sure if switching names of at_verbose
> and at_quiet would help here.

I couldn't think of better names offhand.  I agree the current names
are confusing.

>> @@ -943,11 +944,11 @@
>>  esac
>> 
>>  if test $at_unexpected_count = 0; then
>> -  echo "$at_result"
>> -  echo "$at_result" >&AS_MESSAGE_LOG_FD
>> +  AS_ECHO(["$at_result"])
>> +  AS_ECHO(["$at_result"]) >&AS_MESSAGE_LOG_FD
>>  else
>> -  echo "ERROR: $at_result" >&2
>> -  echo "ERROR: $at_result" >&AS_MESSAGE_LOG_FD
>> +  AS_ECHO(["ERROR: $at_result"]) >&2
>> +  AS_ECHO(["ERROR: $at_result"]) >&AS_MESSAGE_LOG_FD
>>    {
>>      echo
>>      AS_BOX([Summary of the failures.])
>
> These can remain plain echo.
>
>> @@ -1419,7 +1420,7 @@
>>  ))dnl
>>  dnl
>>  m4_ifval(m4_defn([at_reason]),
>> -[echo 'Not enabling shell tracing (command contains 
>> ]m4_defn([at_reason])[)'],
>> +[AS_ECHO(['Not enabling shell tracing (command contains 
>> ]m4_defn([at_reason])[)'])],
>>  [m4_bmatch([$1], [\$],
>>  dnl COMMANDS may contain parameter expansions; expand them at runtime.
>>  [case "AS_ESCAPE([$1], [`"\])" in
>
> Likewise.

Yes, thanks for catching those.

>> -# FIXME: This mishandles values that end in newlines, or have backslashes,
>> -# or are '-n'.  Fixing this will require changing the API.
>> +# FIXME: This mishandles values that end in newlines.
>> +# Fixing this will require changing the API.

> This should have exposure in the testsuite, so the claim is a founded
> one.

I suppose so, but I would rather spend my time fixing the API.
I proposed something along those lines a while ago, but haven't
had a chance to finish it up.

Here's what I installed:

2006-11-25  Paul Eggert  <address@hidden>

        * lib/autotest/general.m4 (AT_INIT): Undo recent changes
        that replaced echo with AS_ECHO where this wasn't necessary.
        Problem reportd by Ralf Wildenhues.
        * lib/m4sugar/m4sh.m4 (_AS_ECHO_PREPARE): Port to Solaris 7,
        where "/usr/bin/printf '%s\n' S" dumps core if S is long.
        This is Sun bug 4206210.  Problem reportd by Ralf Wildenhues.

--- lib/autotest/general.m4     17 Nov 2006 21:04:54 -0000      1.217
+++ lib/autotest/general.m4     25 Nov 2006 09:54:32 -0000
@@ -944,11 +944,11 @@ $at_skip_count tests were skipped." ;;
 esac
 
 if test $at_unexpected_count = 0; then
-  AS_ECHO(["$at_result"])
-  AS_ECHO(["$at_result"]) >&AS_MESSAGE_LOG_FD
+  echo "$at_result"
+  echo "$at_result" >&AS_MESSAGE_LOG_FD
 else
-  AS_ECHO(["ERROR: $at_result"]) >&2
-  AS_ECHO(["ERROR: $at_result"]) >&AS_MESSAGE_LOG_FD
+  echo "ERROR: $at_result" >&2
+  echo "ERROR: $at_result" >&AS_MESSAGE_LOG_FD
   {
     echo
     AS_BOX([Summary of the failures.])
@@ -1420,7 +1420,7 @@ m4_pushdef([at_reason],
 ))dnl
 dnl
 m4_ifval(m4_defn([at_reason]),
-[AS_ECHO(['Not enabling shell tracing (command contains 
]m4_defn([at_reason])[)'])],
+[echo 'Not enabling shell tracing (command contains ]m4_defn([at_reason])[)'],
 [m4_bmatch([$1], [\$],
 dnl COMMANDS may contain parameter expansions; expand them at runtime.
 [case "AS_ESCAPE([$1], [`"\])" in
--- lib/m4sugar/m4sh.m4 17 Nov 2006 21:04:54 -0000      1.202
+++ lib/m4sugar/m4sh.m4 25 Nov 2006 09:54:32 -0000
@@ -808,25 +808,34 @@ m4_defun([_AS_ECHO_PREPARE],
 [[as_nl='
 '
 export as_nl
-case `(printf %s foo) 2>/dev/null` in
-foo)
+# Printing a 2060-byte string crashes Solaris 7 /usr/bin/printf.
+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
+as_echo=$as_echo$as_echo$as_echo$as_echo
+if test "X`(printf %s $as_echo) 2>/dev/null`" = "X$as_echo"; then
   as_echo='printf %s\n'
-  as_echo_n='printf %s';;
-*)
-  as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
-  as_echo_n_body='eval
-    arg=$1;
-    case $arg in
-    *"$as_nl"*)
-      expr "X$arg" : "X\\(.*\\)$as_nl";
-      arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
-    esac;
-    expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
-  '
-  export as_echo_body as_echo_n_body
+  as_echo_n='printf %s'
+else
+  if test "X`PATH=/usr/ucb; echo -n -n $as_echo`" = "X-n $as_echo"; then
+    as_echo_body='PATH=/usr/ucb; eval echo -n "$1$as_nl"'
+    as_echo_n='/usr/ucb/echo -n'
+  else
+    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
+    as_echo_n_body='eval
+      arg=$1;
+      case $arg in
+      *"$as_nl"*)
+       expr "X$arg" : "X\\(.*\\)$as_nl";
+       arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
+      esac;
+      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
+    '
+    export as_echo_n_body
+    as_echo_n='sh -c $as_echo_n_body X'
+  fi
+  export as_echo_body
   as_echo='sh -c $as_echo_body X'
-  as_echo_n='sh -c $as_echo_n_body X';;
-esac
+fi
 ]])# _AS_ECHO_PREPARE
 
 




reply via email to

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