Re: [PATCH] tests/testsuite.at: Don't use $as_echo

Eric Blake <[email protected]>
Newsgroups gmane.comp.gnu.libtool.patches
Organization Red Hat, Inc.
Message-ID <[email protected]>
On 3/13/20 4:27 PM, Zack Weinberg wrote:
> tests/testsuite.at was using the undocumented internal shell variable
> $as_echo to set its own variable $ECHO.  M4sh stopped setting this
> variable in a patch committed to autoconf development trunk in January
> of 2013, which was mostly harmless since there was a fallback setting
> for $ECHO.  As of March 2020, however, merely mentioning $as_echo in
> an m4sh input file will trigger a -Wobsolete warning.
> 
> The fix is to promote the fallback setting to be the default setting
> and not reference $as_echo anymore.  This is safe for the same reason
> it was safe for autoconf to stop setting $as_echo -- 'printf %s\n' is a
> reliable way to do echoing in all of the shells that are worth worrying
> about anymore.
> ---
>   tests/testsuite.at | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/tests/testsuite.at b/tests/testsuite.at
> index d561c2a4..9e33c75a 100644
> --- a/tests/testsuite.at
> +++ b/tests/testsuite.at
> @@ -29,8 +29,7 @@ m4_divert_push([PREPARE_TESTS])dnl
>   : ${AUTOCONF=autoconf}
>   : ${AUTOMAKE=automake}
>   : ${AUTORECONF=autoreconf}
> -test set = "${ECHO+set}" || ECHO=${as_echo-'printf %s\n'}
> -: ${ECHO=$as_echo}
> +: ${ECHO='printf %s\n'}

Side comment: I just realized that:

$ECHO "arg1" "arg2"

is NOT the same as:

echo "arg1" "arg2"

due to use of a newline rather than a space between the arguments.  That 
is, $ECHO is only safe to use with a single argument.  But that fact is 
true regardless of this patch, and I did not bother auditing whether we 
violate that usage pattern anywhere (perhaps we could make $ECHO expand 
to a function call, where the function loudly complains about $# > 1, if 
we wanted to make such an audit easier).

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.