autoconf
[Top][All Lists]
Advanced

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

Re: Using "m4_bpatsubst/patsubst" to remove a string from a variable


From: Eric Blake
Subject: Re: Using "m4_bpatsubst/patsubst" to remove a string from a variable
Date: Mon, 6 Jun 2016 12:21:23 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

On 06/06/2016 07:31 AM, Zack Weinberg wrote:

> or you can do it all in shell:
> 
> VAR="text1 text2"
> VAR2="`AS_ECHO("$VAR") | sed 's/text1//g'`" dnl yes, the nested double
> quotes are correct

Correct in a POSIX shell, but liable to misbehave on some older shells.
 Better is:

VAR2=`AS_ECHO("$VAR") | sed 's/text1//g'`

Since it is in assignment context, you don't need the outer "" to
prevent word splitting, the `` is enough for the shell to know where the
assignment ends.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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