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

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

 



On Mon, Jun 6, 2016 at 2:21 PM, Eric Blake <eblake@xxxxxxxxxx> wrote:
> On 06/06/2016 07:31 AM, Zack Weinberg wrote:
>
>> VAR2="`AS_ECHO("$VAR") | sed 's/text1//g'`"
>
> 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.

I am under the impression that there did once exist shells for which
the outer quotes *were* necessary to prevent word splitting (and
therefore misinterpretation of the overall statement as a
single-command environment variable override).  I am also under the
impression that any shell new enough to implement $() will *not* do
word splitting in a variable assignment.

Both of these factoids come out of the same "bitter experience with
vendor /bin/sh circa 1996" box in my head, so they may be totally
wrong, or they may only apply to shells sufficiently ancient as to be
irrelevant nowadays -- does anyone know for sure?

zw

_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
https://lists.gnu.org/mailman/listinfo/autoconf



[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux